From cbf6d6892f2ad6985099d732ecd1101ed183d30f Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Sat, 26 Nov 2022 22:05:57 +0100 Subject: [PATCH] [IMP] account_fiscal_year : Add fields start date and end date of the current fiscal year on res.company model, and display on the views --- account_fiscal_year/__manifest__.py | 1 + .../i18n/account_fiscal_year.pot | 12 +++++-- account_fiscal_year/i18n/fr.po | 17 +++++++--- account_fiscal_year/models/res_company.py | 21 ++++++++++++- .../views/res_company_views.xml | 31 +++++++++++++++++++ 5 files changed, 74 insertions(+), 8 deletions(-) create mode 100644 account_fiscal_year/views/res_company_views.xml diff --git a/account_fiscal_year/__manifest__.py b/account_fiscal_year/__manifest__.py index 1b48526c3..7c89a0e3d 100644 --- a/account_fiscal_year/__manifest__.py +++ b/account_fiscal_year/__manifest__.py @@ -20,5 +20,6 @@ "security/ir.model.access.csv", "security/account_fiscal_year_rule.xml", "views/account_fiscal_year_views.xml", + "views/res_company_views.xml", ], } diff --git a/account_fiscal_year/i18n/account_fiscal_year.pot b/account_fiscal_year/i18n/account_fiscal_year.pot index 139a36190..9e58e58f7 100644 --- a/account_fiscal_year/i18n/account_fiscal_year.pot +++ b/account_fiscal_year/i18n/account_fiscal_year.pot @@ -48,6 +48,11 @@ msgstr "" msgid "End Date" msgstr "" +#. module: account_fiscal_year +#: model:ir.model.fields,field_description:account_fiscal_year.field_res_company__fiscal_year_date_to +msgid "End Date of the Fiscal Year" +msgstr "" + #. module: account_fiscal_year #: model:ir.model.fields,help:account_fiscal_year.field_account_fiscal_year__date_to msgid "Ending Date, included in the fiscal year." @@ -94,20 +99,23 @@ msgstr "" msgid "Start Date" msgstr "" +#. module: account_fiscal_year +#: model:ir.model.fields,field_description:account_fiscal_year.field_res_company__fiscal_year_date_from +msgid "Start Date of the Fiscal Year" +msgstr "" + #. module: account_fiscal_year #: model:ir.model.fields,help:account_fiscal_year.field_account_fiscal_year__date_from msgid "Start Date, included in the fiscal year." msgstr "" #. module: account_fiscal_year -#. odoo-python #: code:addons/account_fiscal_year/models/account_fiscal_year.py:0 #, python-format msgid "The ending date must not be prior to the starting date." msgstr "" #. module: account_fiscal_year -#. odoo-python #: code:addons/account_fiscal_year/models/account_fiscal_year.py:0 #, python-format msgid "" diff --git a/account_fiscal_year/i18n/fr.po b/account_fiscal_year/i18n/fr.po index e87acf87a..e2a359ff4 100644 --- a/account_fiscal_year/i18n/fr.po +++ b/account_fiscal_year/i18n/fr.po @@ -51,6 +51,11 @@ msgstr "Nom affiché" msgid "End Date" msgstr "Date de fin" +#. module: account_fiscal_year +#: model:ir.model.fields,field_description:account_fiscal_year.field_res_company__fiscal_year_date_to +msgid "End Date of the fiscal year" +msgstr "Date de fin d'exercice" + #. module: account_fiscal_year #: model:ir.model.fields,help:account_fiscal_year.field_account_fiscal_year__date_to msgid "Ending Date, included in the fiscal year." @@ -97,26 +102,28 @@ msgstr "Nom" msgid "Start Date" msgstr "Date de début" +#. module: account_fiscal_year +#: model:ir.model.fields,field_description:account_fiscal_year.field_res_company__fiscal_year_date_from +msgid "Start Date of the fiscal year" +msgstr "Date de début d'exercice" + #. module: account_fiscal_year #: model:ir.model.fields,help:account_fiscal_year.field_account_fiscal_year__date_from msgid "Start Date, included in the fiscal year." msgstr "Date de début, incluse dans l'exercice." #. module: account_fiscal_year -#. odoo-python #: code:addons/account_fiscal_year/models/account_fiscal_year.py:0 #, python-format msgid "The ending date must not be prior to the starting date." msgstr "La date de début doit précéder la date de fin." #. module: account_fiscal_year -#. odoo-python #: code:addons/account_fiscal_year/models/account_fiscal_year.py:0 #, python-format msgid "" "This fiscal year '{fy}' overlaps with '{overlapping_fy}'.\n" "Please correct the start and/or end dates of your fiscal years." msgstr "" - -#~ msgid "Last Modified on" -#~ msgstr "Dernière modification le" +"L'exercice '{fy}' chevauche avec '{overlapping_fy}'.\n" +"Veuillez modifier les dates de début et de fin." diff --git a/account_fiscal_year/models/res_company.py b/account_fiscal_year/models/res_company.py index afe6b0f1c..d87969e57 100644 --- a/account_fiscal_year/models/res_company.py +++ b/account_fiscal_year/models/res_company.py @@ -1,13 +1,32 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from datetime import timedelta -from odoo import models +from odoo import fields, models from odoo.tools import date_utils class ResCompany(models.Model): _inherit = "res.company" + fiscal_year_date_from = fields.Date( + string="Start Date of the Fiscal Year", + compute="_compute_fiscal_year_dates", + compute_sudo=True, + ) + + fiscal_year_date_to = fields.Date( + string="End Date of the Fiscal Year", + compute="_compute_fiscal_year_dates", + compute_sudo=True, + ) + + def _compute_fiscal_year_dates(self): + today = fields.Date.today() + for company in self: + res = company.compute_fiscalyear_dates(today) + company.fiscal_year_date_from = res["date_from"] + company.fiscal_year_date_to = res["date_to"] + def compute_fiscalyear_dates(self, current_date): """Computes the start and end dates of the fiscal year where the given 'date' belongs to. diff --git a/account_fiscal_year/views/res_company_views.xml b/account_fiscal_year/views/res_company_views.xml new file mode 100644 index 000000000..76fdcb437 --- /dev/null +++ b/account_fiscal_year/views/res_company_views.xml @@ -0,0 +1,31 @@ + + + + + + res.company + + + + + + + + + + + res.company + + + + + + + + + +