This commit is contained in:
Alnus Tmp 2021-10-14 03:36:26 +00:00
parent 096ff281cf
commit 9eeef4bdc4
1 changed files with 8 additions and 4 deletions

View File

@ -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')