From 51d91e5d9e809f694ba609e76f2d35f14b663b79 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 19 Sep 2017 10:21:20 +0200 Subject: [PATCH] [FIX] account_financial_report_qweb: Make fy_start_date a computed field --- account_financial_report_qweb/README.rst | 3 ++- account_financial_report_qweb/__openerp__.py | 2 +- .../wizard/general_ledger_wizard.py | 14 +++++++++----- .../wizard/trial_balance_wizard.py | 14 +++++++++----- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/account_financial_report_qweb/README.rst b/account_financial_report_qweb/README.rst index efe611c3..3be48f8f 100644 --- a/account_financial_report_qweb/README.rst +++ b/account_financial_report_qweb/README.rst @@ -37,7 +37,7 @@ Images Contributors ------------ -* Jordi Ballestrer +* Jordi Ballester * Yannick Vaucher * Simone Orsi * Leonardo Pistone @@ -51,6 +51,7 @@ Contributors * Lorenzo Battistini * Julien Coux * Jairo Llopis +* Alexis de Lattre Much of the work in this module was done at a sprint in Sorrento, Italy in April 2016. diff --git a/account_financial_report_qweb/__openerp__.py b/account_financial_report_qweb/__openerp__.py index 97ba3ed2..81d01649 100644 --- a/account_financial_report_qweb/__openerp__.py +++ b/account_financial_report_qweb/__openerp__.py @@ -5,7 +5,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { 'name': 'QWeb Financial Reports', - 'version': '9.0.1.0.4', + 'version': '9.0.1.0.5', 'category': 'Reporting', 'summary': 'OCA Financial Reports', 'author': 'Camptocamp SA,' diff --git a/account_financial_report_qweb/wizard/general_ledger_wizard.py b/account_financial_report_qweb/wizard/general_ledger_wizard.py index 328d77a1..e830c60c 100644 --- a/account_financial_report_qweb/wizard/general_ledger_wizard.py +++ b/account_financial_report_qweb/wizard/general_ledger_wizard.py @@ -2,6 +2,7 @@ # Author: Damien Crier # Author: Julien Coux # Copyright 2016 Camptocamp SA +# Copyright 2017 Akretion - Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from openerp import models, fields, api @@ -25,7 +26,7 @@ class GeneralLedgerReportWizard(models.TransientModel): ) date_from = fields.Date(required=True) date_to = fields.Date(required=True) - fy_start_date = fields.Date(required=True) + fy_start_date = fields.Date(compute='_compute_fy_start_date') target_move = fields.Selection([('posted', 'All Posted Entries'), ('all', 'All Entries')], string='Target Moves', @@ -60,6 +61,13 @@ class GeneralLedgerReportWizard(models.TransientModel): string='Not only one unaffected earnings account' ) + @api.depends('date_from') + def _compute_fy_start_date(self): + for wiz in self.filtered('date_from'): + date = fields.Datetime.from_string(wiz.date_from) + res = self.company_id.compute_fiscalyear_dates(date) + wiz.fy_start_date = res['date_from'] + @api.onchange('company_id') def onchange_company_id(self): """Handle company change.""" @@ -76,10 +84,6 @@ class GeneralLedgerReportWizard(models.TransientModel): """Handle date range change.""" self.date_from = self.date_range_id.date_start self.date_to = self.date_range_id.date_end - if self.date_from: - self.fy_start_date = self.company_id.find_daterange_fy( - fields.Date.from_string(self.date_range_id.date_start) - ).date_start @api.onchange('receivable_accounts_only', 'payable_accounts_only') def onchange_type_accounts_only(self): diff --git a/account_financial_report_qweb/wizard/trial_balance_wizard.py b/account_financial_report_qweb/wizard/trial_balance_wizard.py index 2ddbf12a..12fb19b5 100644 --- a/account_financial_report_qweb/wizard/trial_balance_wizard.py +++ b/account_financial_report_qweb/wizard/trial_balance_wizard.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # Author: Julien Coux # Copyright 2016 Camptocamp SA +# Copyright 2017 Akretion - Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from openerp import models, fields, api @@ -24,7 +25,7 @@ class TrialBalanceReportWizard(models.TransientModel): ) date_from = fields.Date(required=True) date_to = fields.Date(required=True) - fy_start_date = fields.Date(required=True) + fy_start_date = fields.Date(compute='_compute_fy_start_date') target_move = fields.Selection([('posted', 'All Posted Entries'), ('all', 'All Entries')], string='Target Moves', @@ -54,6 +55,13 @@ class TrialBalanceReportWizard(models.TransientModel): string='Not only one unaffected earnings account' ) + @api.depends('date_from') + def _compute_fy_start_date(self): + for wiz in self.filtered('date_from'): + date = fields.Datetime.from_string(wiz.date_from) + res = self.company_id.compute_fiscalyear_dates(date) + wiz.fy_start_date = res['date_from'] + @api.onchange('company_id') def onchange_company_id(self): """Handle company change.""" @@ -70,10 +78,6 @@ class TrialBalanceReportWizard(models.TransientModel): """Handle date range change.""" self.date_from = self.date_range_id.date_start self.date_to = self.date_range_id.date_end - if self.date_from: - self.fy_start_date = self.company_id.find_daterange_fy( - fields.Date.from_string(self.date_range_id.date_start) - ).date_start @api.onchange('receivable_accounts_only', 'payable_accounts_only') def onchange_type_accounts_only(self):