From fb875a3852b8fae5f321a339fea3984ee87c1030 Mon Sep 17 00:00:00 2001 From: Arnaud Joset Date: Thu, 15 Oct 2020 13:46:38 +0000 Subject: [PATCH] [IMP] account: add compute_fiscalyear_dates method on res.company [IMP] account: add compute_fiscalyear_dates method on res.company The following commits https://github.com/odoo/odoo/commit/576a69e29e98532aa5de78eb3fcbff0b94cea32d https://github.com/odoo-dev/enterprise/commit/ed383522791276b17ba68a4f0d08f9e3ed4e783c move the compute_fiscalyear_dates method from the community account module to the enterprise one account_accounting. This commit ensures that the method can be used when account_accounting is not installed. As the fiscal year is irrelevant when account_accounting is not installed, this commit displays the calendar year. taskid: 2329108 See also: taskid 220194 closes odoo/odoo#60140 X-original-commit: 544cb3682033e9f644b48b97dd5197eaf9282ff5 Signed-off-by: Yannick Tivisse (yti) --- addons/account/models/company.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/addons/account/models/company.py b/addons/account/models/company.py index 33297625a6d..b1d5b151259 100644 --- a/addons/account/models/company.py +++ b/addons/account/models/company.py @@ -544,3 +544,16 @@ class ResCompany(models.Model): results_by_journal['results'].append(rslt) return results_by_journal + + def compute_fiscalyear_dates(self, current_date): + """ + The role of this method is to provide a fallback when account_accounting is not installed. + As the fiscal year is irrelevant when account_accounting is not installed, this method returns the calendar year. + :param current_date: A datetime.date/datetime.datetime object. + :return: A dictionary containing: + * date_from + * date_to + """ + + return {'date_from': datetime(year=current_date.year, month=1, day=1).date(), + 'date_to': datetime(year=current_date.year, month=12, day=31).date()}