Hi,
We often use 2 taxes on the same sale (ex. 6% for a product and 21% for a service).
On the original sale report, we could have then a tax amount which the sum of different taxes.
Here’s a small customization for a detailed tax amount like for the invoice report:
Code (it could probably be improved but that do the job ):
from trytond.pool import PoolMeta, Pool
class Sale(metaclass=PoolMeta):
__name__ = 'sale.sale'
@property
def report_tax_resume(self):
pool = Pool()
Tax = pool.get('account.tax')
res = []
for i, v in enumerate(self._get_taxes().values()):
data = {}
tax = Tax(v['tax'])
data['index'] = i +1
data['tax'] = tax
data['tax_name'] = tax.name
data['tax_description'] = tax.description
data['amount'] = v['amount']
res.append(data)
return res
class SaleLine(metaclass=PoolMeta):
__name__ = 'sale.line'
@property
def report_tax_indexes(self):
sale_taxes = self.sale.report_tax_resume
indexes = [t['index'] for t in (sale_taxes) for l in self.taxes
if l in t.values()]
return ','.join('[' + '%s' % i + ']' for i in indexes)
Report: