@@ -353,8 +353,10 @@ class CompanyConfig(Wizard):
|
||||
class CompanyReport(Report):
|
||||
|
||||
@classmethod
|
||||
def header_key(cls, record):
|
||||
return super().header_key(record) + (('company', record.company),)
|
||||
def header_key(cls, record, data):
|
||||
return super().header_key(record, data) + (
|
||||
('company', record.company),
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def get_context(cls, records, header, data):
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
* Add report data to header_key
|
||||
* Validate integer digits
|
||||
* Add support for DATE_TRUNC from INTERVAL to SQLite backend
|
||||
* Add support for EXTRACT from INTERVAL to SQLite backend
|
||||
|
||||
@@ -39,10 +39,11 @@ Class methods are:
|
||||
Verifies if the :attr:`~trytond.transaction.Transaction.user` is allowed to
|
||||
execute the report.
|
||||
|
||||
.. classmethod:: Report.header_key(record)
|
||||
.. classmethod:: Report.header_key(record[, data])
|
||||
|
||||
Returns a tuple of keys, composed of couples of name and record value, used
|
||||
to group document with the same header.
|
||||
``data`` is the dictionary passed to :meth:~Report.execute`.
|
||||
|
||||
.. classmethod:: Report.execute(ids, data)
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import unicodedata
|
||||
import warnings
|
||||
import zipfile
|
||||
from email.message import EmailMessage
|
||||
from functools import partial
|
||||
from io import BytesIO
|
||||
from itertools import groupby
|
||||
|
||||
@@ -175,7 +176,7 @@ class Report(URLMixin, PoolBase):
|
||||
Model.read(ids, ['id'])
|
||||
|
||||
@classmethod
|
||||
def header_key(cls, record):
|
||||
def header_key(cls, record, data):
|
||||
return ()
|
||||
|
||||
@classmethod
|
||||
@@ -240,16 +241,17 @@ class Report(URLMixin, PoolBase):
|
||||
else:
|
||||
records = []
|
||||
|
||||
header_key = partial(cls.header_key, data=data)
|
||||
if not records:
|
||||
groups = [[]]
|
||||
headers = [{}]
|
||||
elif action_report.single:
|
||||
groups = [[r] for r in records]
|
||||
headers = [dict(cls.header_key(r)) for r in records]
|
||||
headers = [dict(header_key(r)) for r in records]
|
||||
else:
|
||||
groups = []
|
||||
headers = []
|
||||
for key, group in groupby(records, key=cls.header_key):
|
||||
for key, group in groupby(records, key=header_key):
|
||||
groups.append(list(group))
|
||||
headers.append(dict(key))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user