2
0

[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
This commit is contained in:
Sylvain LE GAL 2022-11-04 00:10:13 +01:00
parent 88840c2df8
commit d8d2534a76
5 changed files with 9 additions and 42 deletions

View File

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

View File

@ -8,7 +8,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
<record id="cron_fiscal_year_auto_create" model="ir.cron">
<field name="name">Auto Create Fiscal Years</field>
<field name="active" eval="True" />
<field name="model_id" ref="account.model_account_fiscal_year" />
<field name="model_id" ref="account_fiscal_year.model_account_fiscal_year" />
<field name="state">code</field>
<field name="code">model.cron_auto_create()</field>
<field name="interval_number">1</field>

View File

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

View File

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

View File

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