[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
This commit is contained in:
parent
11ba4689b1
commit
529af0c95d
|
@ -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])
|
||||
|
|
Loading…
Reference in New Issue