2
0

[MIG] account_asset_batch_compute: Migration to 16.0

This commit is contained in:
Javier Iniesta 2023-03-13 11:16:44 +01:00
parent 7015c3eb6d
commit 8adec89580
6 changed files with 88 additions and 30 deletions

View File

@ -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",

View File

@ -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"
@ -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

View File

@ -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"

View File

@ -15,9 +15,11 @@ class AccountAsset(models.Model):
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

View File

@ -12,38 +12,35 @@ from odoo.addons.queue_job.job import Job
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"),
@ -55,8 +52,8 @@ class TestAccountAssetBatchCompute(TransactionCase):
)
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(

View File

@ -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()