From 9eeef4bdc41bb2a59115863e9c10d88fd88c9863 Mon Sep 17 00:00:00 2001 From: Alnus Tmp Date: Thu, 14 Oct 2021 03:36:26 +0000 Subject: [PATCH] fixes #1 --- invoice.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/invoice.py b/invoice.py index 1b566d9..d33c536 100644 --- a/invoice.py +++ b/invoice.py @@ -5,8 +5,9 @@ from trytond.modules.product import price_digits from trytond.transaction import Transaction from trytond.pyson import If, Eval, Bool from trytond.exceptions import UserError +from trytond.modules.account.tax import TaxableMixin + - class InvoiceLine(metaclass=PoolMeta): 'Invoice Line' __name__ = 'account.invoice.line' @@ -26,7 +27,7 @@ class InvoiceLine(metaclass=PoolMeta): unit_price_days = fields.Numeric('Unit Price Days', digits=price_digits) - + @property def taxable_lines(self): # In case we're called from an on_change we have to use some sensible @@ -38,6 +39,7 @@ class InvoiceLine(metaclass=PoolMeta): else: invoice_type = getattr(self, 'invoice_type', None) if invoice_type == 'in': + unit_price = 'unit_price' if context.get('_deductible_rate') is not None: deductible_rate = context['_deductible_rate'] else: @@ -48,14 +50,16 @@ class InvoiceLine(metaclass=PoolMeta): return [] else: deductible_rate = 1 + unit_price = 'unit_price_days' + return [( getattr(self, 'taxes', None) or [], - ((getattr(self, 'unit_price_days', None) or Decimal(0)) + ((getattr(self, unit_price, None) or Decimal(0)) * deductible_rate), getattr(self, 'quantity', None) or 0, getattr(self, 'tax_date', None), )] - + @fields.depends('type', 'quantity', 'unit_price', 'invoice', '_parent_invoice.currency', 'currency', 'rental_days', 'unit_price_days', 'invoice_type')