Skip to content

Commit

Permalink
[MIG] account_asset_batch_compute: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Javier Iniesta committed May 29, 2023
1 parent 7015c3e commit 8adec89
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 30 deletions.
2 changes: 1 addition & 1 deletion account_asset_batch_compute/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "Account Asset Batch Compute",
"summary": """
Add the possibility to compute assets in batch""",
"version": "14.0.1.0.0",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV,ForgeFlow,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/account-financial-tools",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
Expand All @@ -31,13 +31,13 @@ msgstr ""
#. module: account_asset_batch_compute
#: code:addons/account_asset_batch_compute/wizards/account_asset_compute.py:0
#, python-format
msgid "Creating jobs to create moves for assets to %s"
msgid "Creating jobs to create moves for assets to {}"
msgstr ""

#. module: account_asset_batch_compute
#: code:addons/account_asset_batch_compute/models/account_asset.py:0
#, python-format
msgid "Creating move for asset with id %s to %s"
msgid "Creating move for asset with id {rec_id} to {date_end}"
msgstr ""

#. module: account_asset_batch_compute
Expand Down
59 changes: 59 additions & 0 deletions account_asset_batch_compute/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_asset_batch_compute
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: account_asset_batch_compute
#: model:ir.model,name:account_asset_batch_compute.model_account_asset
msgid "Asset"
msgstr "Activo"

#. module: account_asset_batch_compute
#: model:ir.model.fields,field_description:account_asset_batch_compute.field_account_asset_compute__batch_processing
msgid "Batch Processing"
msgstr "Procesamiento por lotes"

#. module: account_asset_batch_compute
#: model:ir.model,name:account_asset_batch_compute.model_account_asset_compute
msgid "Compute Assets"
msgstr "Calcular activos"

#. module: account_asset_batch_compute
#: code:addons/account_asset_batch_compute/wizards/account_asset_compute.py:0
#, python-format
msgid "Creating jobs to create moves for assets to {}"
msgstr "Creando trabajos para crear movimientos de activos a {}"

#. module: account_asset_batch_compute
#: code:addons/account_asset_batch_compute/models/account_asset.py:0
#, python-format
msgid "Creating move for asset with id {rec_id} to {date_end}"
msgstr "Creando movimiento de activo con id {rec_id} a {date_end}"

#. module: account_asset_batch_compute
#: model:ir.model.fields,field_description:account_asset_batch_compute.field_account_asset__display_name
#: model:ir.model.fields,field_description:account_asset_batch_compute.field_account_asset_compute__display_name
msgid "Display Name"
msgstr "Nombre a mostrar"

#. module: account_asset_batch_compute
#: model:ir.model.fields,field_description:account_asset_batch_compute.field_account_asset__id
#: model:ir.model.fields,field_description:account_asset_batch_compute.field_account_asset_compute__id
msgid "ID"
msgstr "ID"

#. module: account_asset_batch_compute
#: model:ir.model.fields,field_description:account_asset_batch_compute.field_account_asset____last_update
#: model:ir.model.fields,field_description:account_asset_batch_compute.field_account_asset_compute____last_update
msgid "Last Modified on"
msgstr "Última modificación en"
8 changes: 5 additions & 3 deletions account_asset_batch_compute/models/account_asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ def _compute_entries(self, date_end, check_triggers=False):
results = []
log_error = ""
for record in self:
description = _("Creating move for asset with id %s to %s") % (
record.id,
date_end,
description = _(
"Creating move for asset with id {rec_id} to {date_end}"
).format(
rec_id=record.id,
date_end=date_end,
)
record.with_delay(description=description)._compute_entries(
date_end, check_triggers=check_triggers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,35 @@


class TestAccountAssetBatchCompute(TransactionCase):
def setUp(self):
super(TestAccountAssetBatchCompute, self).setUp()
self.wiz_obj = self.env["account.asset.compute"]
self.asset_model = self.env["account.asset"]
self.asset_profile_model = self.env["account.asset.profile"]
self.account_account_type_model = self.env["account.account.type"]
self.account_type_regular = self.account_account_type_model.create(
{"name": "Test Regular", "type": "other", "internal_group": "liability"}
)
self.account = self.env["account.account"].create(
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.wiz_obj = cls.env["account.asset.compute"]
cls.asset_model = cls.env["account.asset"]
cls.asset_profile_model = cls.env["account.asset.profile"]
cls.account = cls.env["account.account"].create(
{
"name": "Test account",
"code": "TAC",
"user_type_id": self.account_type_regular.id,
"account_type": "liability_payable",
}
)
self.journal = self.env["account.journal"].create(
cls.journal = cls.env["account.journal"].create(
{"name": "Test Journal", "code": "TJ", "type": "general"}
)
self.profile = self.asset_profile_model.create(
cls.profile = cls.asset_profile_model.create(
{
"account_expense_depreciation_id": self.account.id,
"account_asset_id": self.account.id,
"account_depreciation_id": self.account.id,
"journal_id": self.journal.id,
"account_expense_depreciation_id": cls.account.id,
"account_asset_id": cls.account.id,
"account_depreciation_id": cls.account.id,
"journal_id": cls.journal.id,
"name": "Test",
}
)
self.asset01 = self.asset_model.create(
cls.asset01 = cls.asset_model.create(
{
"name": "test asset",
"profile_id": self.profile.id,
"profile_id": cls.profile.id,
"purchase_value": 1000,
"salvage_value": 0,
"date_start": time.strftime("2003-01-01"),
Expand All @@ -55,8 +52,8 @@ def setUp(self):
)
today = date.today()
first_day_of_month = date(today.year, today.month, 1)
self.nextmonth = first_day_of_month + relativedelta.relativedelta(months=1)
self.asset01.date_start = first_day_of_month
cls.nextmonth = first_day_of_month + relativedelta.relativedelta(months=1)
cls.asset01.date_start = first_day_of_month

def test_no_batch_processing(self):
wiz = self.wiz_obj.create(
Expand Down
4 changes: 2 additions & 2 deletions account_asset_batch_compute/wizards/account_asset_compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ class AccountAssetCompute(models.TransientModel):
def asset_compute(self):
self.ensure_one()
if not self.batch_processing:
return super(AccountAssetCompute, self).asset_compute()
return super().asset_compute()
if not self.env.context.get("job_uuid") and not self.env.context.get(
"test_queue_job_no_delay"
):
description = _("Creating jobs to create moves for assets to %s") % (
description = _("Creating jobs to create moves for assets to {}").format(
self.date_end,
)
job = self.with_delay(description=description).asset_compute()
Expand Down

0 comments on commit 8adec89

Please sign in to comment.