From 529af0c95d51205f68ce6ad4a6810cb4aa9bedd6 Mon Sep 17 00:00:00 2001 From: vrenaville Date: Tue, 23 Jun 2015 11:03:41 +0200 Subject: [PATCH] [FIX] VAT Report: Fiscalyear and period selection In the Account Tax Decalaration wizard, Accounting > Reporting > Generic Reporting > Taxes > Taxes Report, When not choosing the start/end period, but choosing a fiscal year, the fiscal year was simply ignored, the report took a fiscal year randomly. In addition, if no fiscal year was chosen, the fiscal year randomly chosen could even not be a fiscal year of the right company, in a multi-company environment. closes #7219 opw-643194 --- addons/account/report/report_vat.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/addons/account/report/report_vat.py b/addons/account/report/report_vat.py index 3e2c82fc457..8ac2ba07260 100644 --- a/addons/account/report/report_vat.py +++ b/addons/account/report/report_vat.py @@ -41,10 +41,12 @@ class tax_report(report_sxw.rml_parse, common_report_header): } } self.period_ids = [] + self.fiscalyear_id = False period_obj = self.pool.get('account.period') self.display_detail = data['form']['display_detail'] res['periods'] = '' res['fiscalyear'] = data['form'].get('fiscalyear_id', False) + self.fiscalyear_id = res['fiscalyear'] if data['form'].get('period_from', False) and data['form'].get('period_to', False): self.period_ids = period_obj.build_ctx_periods(self.cr, self.uid, data['form']['period_from'], data['form']['period_to']) @@ -76,13 +78,18 @@ class tax_report(report_sxw.rml_parse, common_report_header): def _get_lines(self, based_on, company_id=False, parent=False, level=0, context=None): period_list = self.period_ids + fiscalyear_id = self.fiscalyear_id res = self._get_codes(based_on, company_id, parent, level, period_list, context=context) if period_list: res = self._add_codes(based_on, res, period_list, context=context) else: - self.cr.execute ("select id from account_fiscalyear") - fy = self.cr.fetchall() - self.cr.execute ("select id from account_period where fiscalyear_id = %s",(fy[0][0],)) + if not fiscalyear_id: + self.cr.execute("select id from account_fiscalyear where company_id = %s", (company_id,)) + result = self.cr.fetchall() + fy = [x[0] for x in result] + else: + fy = [fiscalyear_id] + self.cr.execute("select id from account_period where fiscalyear_id = ANY(%s)", (fy,)) periods = self.cr.fetchall() for p in periods: period_list.append(p[0])