Add header grouping on report

issue6760
review351221002
This commit is contained in:
Cédric Krier committed 2021-02-21 19:19:26 +01:00
1 parent 94c8a6a053
commit e38d685bc9
4 files changed
+32 -31

No files matched your search

+19 -23
View File
@@ -89,13 +89,10 @@ def strip_accents(s):
class AEATReport(Report):
@classmethod
def get_context(cls, records, data):
pool = Pool()
Period = pool.get('account.period')
context = super().get_context(records, data)
def get_context(cls, records, header, data):
context = super().get_context(records, header, data)
periods = sorted(
Period.browse(data['periods']), key=attrgetter('start_date'))
periods = sorted(records, key=attrgetter('start_date'))
context['year'] = str(periods[0].start_date.year)
context['company'] = periods[0].fiscalyear.company
@@ -112,7 +109,7 @@ class AEATReport(Report):
context['format_integer'] = format_integer
context['format_percentage'] = format_percentage
with Transaction().set_context(periods=data['periods']):
with Transaction().set_context(periods=data['ids']):
context['amounts'] = cls.compute_amounts()
return context
@@ -160,14 +157,14 @@ class AEATPartyReport(AEATReport):
return Case((is_invoice, invoice.party), else_=Null), tables
@classmethod
def get_context(cls, records, data):
def get_context(cls, records, header, data):
pool = Pool()
Move = pool.get('account.move')
Line = pool.get('account.move.line')
TaxLine = pool.get('account.tax.line')
Tax = pool.get('account.tax')
context = super().get_context(records, data)
context = super().get_context(records, header, data)
cursor = Transaction().connection.cursor()
move = Move.__table__()
@@ -192,7 +189,7 @@ class AEATPartyReport(AEATReport):
for line in tax_code.lines:
domain.append(line._line_domain)
with Transaction().set_context(periods=data['periods']):
with Transaction().set_context(periods=data['ids']):
tax_line_domain = [Tax._amount_domain(), domain]
_, where = Move.search_domain([
('lines', 'where', [
@@ -216,8 +213,8 @@ class AEAT111(AEATPartyReport):
_aeat_report = '111'
@classmethod
def get_context(cls, records, data):
context = super().get_context(records, data)
def get_context(cls, records, header, data):
context = super().get_context(records, header, data)
amounts = context['amounts']
for code in ['28', '30']:
assert code not in amounts, (
@@ -234,8 +231,8 @@ class AEAT115(AEATPartyReport):
_aeat_report = '115'
@classmethod
def get_context(cls, records, data):
context = super().get_context(records, data)
def get_context(cls, records, header, data):
context = super().get_context(records, header, data)
amounts = context['amounts']
assert '05' not in amounts, (
"computed code 05 already defined")
@@ -254,16 +251,15 @@ class AEAT303(AEATReport):
return amounts
@classmethod
def get_context(cls, records, data):
def get_context(cls, records, header, data):
pool = Pool()
Period = pool.get('account.period')
Account = pool.get('account.account')
TaxCodeLine = pool.get('account.tax.code.line')
transaction = Transaction()
context = super().get_context(records, data)
context = super().get_context(records, header, data)
amounts = context['amounts']
periods = Period.browse(data['periods'])
periods = records
start_date = periods[0].start_date
end_date = periods[-1].end_date
@@ -357,7 +353,7 @@ class PrintAEAT(Wizard):
return 'model_%s' % self.start.report
def open_report(self, action):
return action, {'periods': [p.id for p in self.start.periods]}
return action, {'ids': [p.id for p in self.start.periods]}
do_model_111 = open_report
do_model_115 = open_report
@@ -527,12 +523,12 @@ class AEAT347(Report):
__name__ = 'account.reporting.aeat347'
@classmethod
def get_context(cls, records, data):
def get_context(cls, records, header, data):
pool = Pool()
Company = pool.get('company.company')
t_context = Transaction().context
context = super().get_context(records, data)
context = super().get_context(records, header, data)
context['year'] = str(t_context['date'].year)
context['company'] = Company(t_context['company'])
@@ -658,12 +654,12 @@ class AEAT349(Report):
__name__ = 'account.reporting.aeat349'
@classmethod
def get_context(cls, records, data):
def get_context(cls, records, header, data):
pool = Pool()
Company = pool.get('company.company')
t_context = Transaction().context
context = super().get_context(records, data)
context = super().get_context(records, header, data)
context['company'] = Company(t_context['company'])
context['records_amount'] = sum(
+5
View File
@@ -6,6 +6,7 @@ this repository contains the full copyright notices and license terms. -->
<record model="ir.action.report" id="report_aeat_111">
<field name="name">AEAT Model 111</field>
<field name="model">account.period</field>
<field name="report_name">account.reporting.aeat111</field>
<field name="report">account_es/aeat111.txt</field>
<field name="template_extension">txt</field>
@@ -18,6 +19,7 @@ this repository contains the full copyright notices and license terms. -->
<record model="ir.action.report" id="report_aeat_115">
<field name="name">AEAT Model 115</field>
<field name="model">account.period</field>
<field name="report_name">account.reporting.aeat115</field>
<field name="report">account_es/aeat115.txt</field>
<field name="template_extension">txt</field>
@@ -30,6 +32,7 @@ this repository contains the full copyright notices and license terms. -->
<record model="ir.action.report" id="report_aeat_303">
<field name="name">AEAT Model 303</field>
<field name="model">account.period</field>
<field name="report_name">account.reporting.aeat303</field>
<field name="report">account_es/aeat303.txt</field>
<field name="template_extension">txt</field>
@@ -107,6 +110,7 @@ this repository contains the full copyright notices and license terms. -->
<record model="ir.action.report" id="report_aeat_347">
<field name="name">AEAT Model 347</field>
<field name="model">account.reporting.vat_list_es</field>
<field name="report_name">account.reporting.aeat347</field>
<field name="report">account_es/aeat347.txt</field>
<field name="template_extension">txt</field>
@@ -154,6 +158,7 @@ this repository contains the full copyright notices and license terms. -->
<record model="ir.action.report" id="report_aeat_349">
<field name="name">AEAT Model 349</field>
<field name="model">account.reporting.es_ec_operation_list</field>
<field name="report_name">account.reporting.aeat349</field>
<field name="report">account_es/aeat349.txt</field>
<field name="template_extension">txt</field>
+6 -6
View File
@@ -170,8 +170,8 @@ Generate aeat reports::
>>> with file_open('account_es/tests/111.txt') as f:
... content == f.read()
True
>>> name
'AEAT Model 111'
>>> name.startswith('AEAT Model 111')
True
>>> aeat = Wizard('account.reporting.aeat')
>>> aeat.form.report = '115'
@@ -184,8 +184,8 @@ Generate aeat reports::
>>> with file_open('account_es/tests/115.txt') as f:
... content == f.read()
True
>>> name
'AEAT Model 115'
>>> name.startswith('AEAT Model 115')
True
>>> aeat = Wizard('account.reporting.aeat')
>>> aeat.form.report = '303'
@@ -197,8 +197,8 @@ Generate aeat reports::
>>> with file_open('account_es/tests/303.txt') as f:
... content == f.read()
True
>>> name
'AEAT Model 303'
>>> name.startswith('AEAT Model 303')
True
>>> VatList = Model.get('account.reporting.vat_list_es')
>>> context = {
+2 -2
View File
@@ -133,5 +133,5 @@ Generate aeat 303 report::
>>> with file_open('account_es/tests/303_compensate.txt') as f:
... content == f.read()
True
>>> name
'AEAT Model 303'
>>> name.startswith('AEAT Model 303')
True