Skip to content

Commit

Permalink
vat transactions report sort
Browse files Browse the repository at this point in the history
  • Loading branch information
luc-demeyer committed Aug 10, 2019
1 parent f541357 commit 7e661de
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
2 changes: 1 addition & 1 deletion l10n_be_coa_multilang/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{
'name': 'Belgium - Multilingual Chart of Accounts (en/nl/fr)',
'version': '11.0.1.2.0',
'version': '11.0.1.2.1',
'license': 'AGPL-3',
'author': "Noviat",
'website': 'http://www.noviat.com',
Expand Down
30 changes: 20 additions & 10 deletions l10n_be_coa_multilang/wizards/l10n_be_vat_declaration.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import base64
import logging
from lxml import etree
import time

from odoo import api, fields, models, _
from odoo.tools.translate import translate
Expand Down Expand Up @@ -489,6 +490,7 @@ def _node_Data(self, VATDeclaration, ns_map):
class l10nBeVatDeclarationCase(models.TransientModel):
_name = 'l10n.be.vat.declaration.case'
_order = 'sequence'
_description = 'Periodical VAT Declaration line'

declaration_id = fields.Many2one(
comodel_name='l10n.be.vat.declaration',
Expand Down Expand Up @@ -1069,19 +1071,23 @@ def _get_journal_ws_params(self, wb, data, decl, journal):
decl.company_id.name,
journal.name + '({})'.format(journal.code),
decl.period])
col_specs_summary = self._get_vat_summary_template()
ws_params_summary = {
'col_specs': self._get_vat_summary_template(),
'wanted_list': ['tax_code', 'tax_amount'],
}
return {
'ws_name': journal.code,
'generate_ws_method': '_journal_report',
'title': title,
'wanted_list': wl,
'col_specs': col_specs,
'col_specs_summary': col_specs_summary,
'ws_params_summary': ws_params_summary,
'journal': journal,
}

def _journal_report(self, wb, ws, ws_params, data, decl):

time_start = time.time()
ws.set_landscape()
ws.fit_to_pages(1, 0)
ws.set_header(self.xls_headers['standard'])
Expand All @@ -1095,6 +1101,11 @@ def _journal_report(self, wb, ws, ws_params, data, decl):
decl, journal)
row_pos = self._journal_lines(ws, row_pos, ws_params, data,
decl, journal)
time_end = time.time() - time_start
_logger.debug(
"VAT Transaction report processing time for "
"Journal %s = %.3f seconds",
journal.code, time_end)

def _journal_title(self, ws, row_pos, ws_params, data, decl, journal):
return self._write_ws_title(ws, row_pos, ws_params)
Expand All @@ -1112,8 +1123,10 @@ def _journal_lines(self, ws, row_pos, ws_params, data, decl, journal):

ws.freeze_panes(row_pos, 0)

aml_dom = self._date_dom + [('journal_id', '=', journal.id)]
amls = self.env['account.move.line'].search(aml_dom, order='date')
am_dom = self._date_dom + [('journal_id', '=', journal.id)]
ams = self.env['account.move'].search(
am_dom, order='name, date')
amls = ams.mapped('line_ids')

tax_totals = {}
tax_map = decl._get_tax_map()
Expand Down Expand Up @@ -1168,20 +1181,17 @@ def _journal_lines(self, ws, row_pos, ws_params, data, decl, journal):
},
default_format=self.format_theader_yellow_left)

col_specs_summary = ws_params['col_specs_summary']
wanted_list_summary = ['tax_code', 'tax_amount']
ws_params['col_specs'] = col_specs_summary
ws_params['wanted_list'] = wanted_list_summary
ws_params_summary = ws_params['ws_params_summary']
row_pos += 1
tcs = list(tax_totals.keys())
tcs.sort()
if tcs:
row_pos = self._write_line(
ws, row_pos, ws_params, col_specs_section='header',
ws, row_pos, ws_params_summary, col_specs_section='header',
default_format=self.format_theader_yellow_left)
for tc in tcs:
row_pos = self._write_line(
ws, row_pos, ws_params, col_specs_section='lines',
ws, row_pos, ws_params_summary, col_specs_section='lines',
render_space={
'l': aml,
'tc': tc,
Expand Down

0 comments on commit 7e661de

Please sign in to comment.