mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
[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
This commit is contained in:
@@ -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",
|
||||
],
|
||||
}
|
||||
|
||||
@@ -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 ""
|
||||
|
||||
@@ -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."
|
||||
|
||||
@@ -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.
|
||||
|
||||
31
account_fiscal_year/views/res_company_views.xml
Normal file
31
account_fiscal_year/views/res_company_views.xml
Normal file
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!--
|
||||
Copyright (C) 2022 - Today: GRAP (http://www.grap.coop)
|
||||
@author: Sylvain LE GAL (https://twitter.com/legalsylvain)
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
-->
|
||||
<odoo>
|
||||
|
||||
<record id="res_company_view_tree" model="ir.ui.view">
|
||||
<field name="model">res.company</field>
|
||||
<field name="inherit_id" ref="base.view_company_tree" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="partner_id" position="after">
|
||||
<field name="fiscal_year_date_from" optional="show" />
|
||||
<field name="fiscal_year_date_to" optional="show" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="res_company_view_form" model="ir.ui.view">
|
||||
<field name="model">res.company</field>
|
||||
<field name="inherit_id" ref="base.view_company_form" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="currency_id" position="after">
|
||||
<field name="fiscal_year_date_from" />
|
||||
<field name="fiscal_year_date_to" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user