From d8d2534a762836a34c2b8fb6c6e94636ae286beb Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Fri, 4 Nov 2022 00:10:13 +0100 Subject: [PATCH] [MIG] account_fiscal_year_auto_create: from 12.0 to 16.0. - depends on new OCA module account_fiscal_year - bump version - use new python convention --- .../__manifest__.py | 4 +-- .../data/ir_cron.xml | 2 +- account_fiscal_year_auto_create/l18n/fr.po | 35 ------------------- .../models/account_fiscal_year.py | 7 ++-- .../tests/test_module.py | 3 +- 5 files changed, 9 insertions(+), 42 deletions(-) delete mode 100644 account_fiscal_year_auto_create/l18n/fr.po diff --git a/account_fiscal_year_auto_create/__manifest__.py b/account_fiscal_year_auto_create/__manifest__.py index 3c626186..a97a3506 100644 --- a/account_fiscal_year_auto_create/__manifest__.py +++ b/account_fiscal_year_auto_create/__manifest__.py @@ -6,14 +6,14 @@ "name": "Fiscal Years - Automatic Creation", "summary": "Automatically create new fiscal years, based on the datas" " of the last fiscal years", - "version": "12.0.1.0.1", + "version": "16.0.1.0.1", "category": "Accounting", "author": "GRAP,Odoo Community Association (OCA)", "maintainers": ["legalsylvain"], "website": "https://github.com/OCA/account-financial-tools", "license": "AGPL-3", "depends": [ - "account", + "account_fiscal_year", ], "data": [ "data/ir_cron.xml", diff --git a/account_fiscal_year_auto_create/data/ir_cron.xml b/account_fiscal_year_auto_create/data/ir_cron.xml index 38807d7d..46b4e35b 100644 --- a/account_fiscal_year_auto_create/data/ir_cron.xml +++ b/account_fiscal_year_auto_create/data/ir_cron.xml @@ -8,7 +8,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). Auto Create Fiscal Years - + code model.cron_auto_create() 1 diff --git a/account_fiscal_year_auto_create/l18n/fr.po b/account_fiscal_year_auto_create/l18n/fr.po deleted file mode 100644 index 094710bc..00000000 --- a/account_fiscal_year_auto_create/l18n/fr.po +++ /dev/null @@ -1,35 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * account_fiscal_year_auto_create -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 12.0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-03-31 08:41+0000\n" -"PO-Revision-Date: 2021-03-31 08:41+0000\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_fiscal_year_auto_create -#: model:ir.actions.server,name:account_fiscal_year_auto_create.cron_fiscal_year_auto_create_ir_actions_server -#: model:ir.cron,cron_name:account_fiscal_year_auto_create.cron_fiscal_year_auto_create -#: model:ir.cron,name:account_fiscal_year_auto_create.cron_fiscal_year_auto_create -msgid "Auto Create Fiscal Years" -msgstr "Création automatique d'année fiscales" - -#. module: account_fiscal_year_auto_create -#: code:addons/account_fiscal_year_auto_create/models/account_fiscal_year.py:45 -#, python-format -msgid "FY %s - %s" -msgstr "AF %s - %s" - -#. module: account_fiscal_year_auto_create -#: model:ir.model,name:account_fiscal_year_auto_create.model_account_fiscal_year -msgid "Fiscal Year" -msgstr "Exercice fiscal" - diff --git a/account_fiscal_year_auto_create/models/account_fiscal_year.py b/account_fiscal_year_auto_create/models/account_fiscal_year.py index 09694f7e..145dc5fc 100644 --- a/account_fiscal_year_auto_create/models/account_fiscal_year.py +++ b/account_fiscal_year_auto_create/models/account_fiscal_year.py @@ -25,7 +25,6 @@ class AccountFiscalYear(models.Model): ): self.create(last_fiscal_year._prepare_next_fiscal_year()) - @api.multi def _prepare_next_fiscal_year(self): self.ensure_one() # try to generate a new name, based on the previous @@ -39,7 +38,11 @@ class AccountFiscalYear(models.Model): [("name", "=", new_name), ("company_id", "=", self.company_id.id)] ): # the replace process fail to guess a correct unique name - new_name = _("FY %s - %s") % (str(self.date_to), str(self.date_from)) + new_name = _( + "FY %(date_to)s - %(date_from)s", + date_to=str(self.date_to), + date_from=str(self.date_from), + ) # compute new dates, handling leap years new_date_from = self.date_to + relativedelta(days=1) new_date_to = new_date_from + relativedelta(years=1, days=-1) diff --git a/account_fiscal_year_auto_create/tests/test_module.py b/account_fiscal_year_auto_create/tests/test_module.py index 203fc7f7..379af291 100644 --- a/account_fiscal_year_auto_create/tests/test_module.py +++ b/account_fiscal_year_auto_create/tests/test_module.py @@ -29,10 +29,10 @@ class TestModule(TransactionCase): ) def test_cron(self): + # Run cron should create a new fiscal year existing_fiscal_years = self.AccountFiscalYear.search([]) self.AccountFiscalYear.cron_auto_create() - # Run cron should create a new fiscal year new_fiscal_year = self.AccountFiscalYear.search( [("id", "not in", existing_fiscal_years.ids)] ) @@ -46,7 +46,6 @@ class TestModule(TransactionCase): existing_fiscal_years = self.AccountFiscalYear.search([]) self.AccountFiscalYear.cron_auto_create() - # Run cron should create a new fiscal year new_fiscal_year = self.AccountFiscalYear.search( [("id", "not in", existing_fiscal_years.ids)] )