details: https://code.tryton.org/tryton/commit/b8e810b49b3b
branch: default
user: Cédric Krier <[email protected]>
date: Sat Jan 17 12:54:09 2026 +0100
description:
Add depends on methods of TaxableMixin
diffstat:
modules/account/tax.py | 6 +++++-
modules/account_invoice/invoice.py | 25 ++++++++++++++-----------
modules/account_tax_non_deductible/account.py | 6 +++---
modules/purchase/purchase.py | 1 +
modules/sale/sale.py | 14 +++++++-------
modules/sale_point/sale.py | 5 +++++
modules/sale_promotion/sale.py | 12 ++++++------
modules/sale_rental/sale.py | 12 ++++++------
8 files changed, 47 insertions(+), 34 deletions(-)
diffs (259 lines):
diff -r b2ab8b67ca33 -r b8e810b49b3b modules/account/tax.py
--- a/modules/account/tax.py Sat Jan 17 12:53:33 2026 +0100
+++ b/modules/account/tax.py Sat Jan 17 12:54:09 2026 +0100
@@ -1231,6 +1231,7 @@
return []
@property
+ @fields.depends('company')
def tax_date(self):
"Date to use when computing the tax"
pool = Pool()
@@ -1241,6 +1242,7 @@
def _get_tax_context(self):
return {}
+ @fields.depends('currency')
def _compute_tax_line(self, amount, base, tax):
if base >= 0:
type_ = 'invoice'
@@ -1280,7 +1282,9 @@
if abs(remainder) < self.currency.rounding:
break
- @fields.depends('company', methods=['_get_tax_context', '_round_taxes'])
+ @fields.depends('company', methods=[
+ 'taxable_lines', 'tax_date', '_get_tax_context',
+ '_compute_tax_line', '_round_taxes'])
def _get_taxes(self):
pool = Pool()
Tax = pool.get('account.tax')
diff -r b2ab8b67ca33 -r b8e810b49b3b modules/account_invoice/invoice.py
--- a/modules/account_invoice/invoice.py Sat Jan 17 12:53:33 2026 +0100
+++ b/modules/account_invoice/invoice.py Sat Jan 17 12:54:09 2026 +0100
@@ -1154,6 +1154,7 @@
return result
@property
+ @fields.depends('lines', 'type')
def taxable_lines(self):
taxable_lines = []
for line in self.lines:
@@ -2718,20 +2719,21 @@
return 1
@property
+ @fields.depends(
+ 'invoice', '_parent_invoice.type', 'invoice_type',
+ 'taxes_deductible_rate', 'taxes', 'unit_price', 'quantity',
+ methods=['tax_date'])
def taxable_lines(self):
- # In case we're called from an on_change we have to use some sensible
- # defaults
context = Transaction().context
- if (getattr(self, 'invoice', None)
- and getattr(self.invoice, 'type', None)):
+ if self.invoice and self.invoice.type:
invoice_type = self.invoice.type
else:
- invoice_type = getattr(self, 'invoice_type', None)
+ invoice_type = self.invoice_type
if invoice_type == 'in':
if context.get('_deductible_rate') is not None:
deductible_rate = context['_deductible_rate']
else:
- deductible_rate = getattr(self, 'taxes_deductible_rate', 1)
+ deductible_rate = self.taxes_deductible_rate
if deductible_rate is None:
deductible_rate = 1
if not deductible_rate:
@@ -2739,14 +2741,14 @@
else:
deductible_rate = 1
return [(
- list(getattr(self, 'taxes', None)) or [],
- ((getattr(self, 'unit_price', None) or Decimal(0))
- * deductible_rate),
- getattr(self, 'quantity', None) or 0,
- getattr(self, 'tax_date', None),
+ list(self.taxes or []),
+ (self.unit_price or Decimal(0)) * deductible_rate,
+ self.quantity or 0,
+ self.tax_date,
)]
@property
+ @fields.depends('taxes_date', 'invoice', '_parent_invoice.id')
def tax_date(self):
if getattr(self, 'taxes_date', None):
return self.taxes_date
@@ -2755,6 +2757,7 @@
else:
return super().tax_date
+ @fields.depends('invoice', '_parent_invoice.id', 'company')
def _get_tax_context(self):
if self.invoice:
return self.invoice._get_tax_context()
diff -r b2ab8b67ca33 -r b8e810b49b3b
modules/account_tax_non_deductible/account.py
--- a/modules/account_tax_non_deductible/account.py Sat Jan 17 12:53:33
2026 +0100
+++ b/modules/account_tax_non_deductible/account.py Sat Jan 17 12:54:09
2026 +0100
@@ -53,14 +53,14 @@
return amount
@property
+ @fields.depends('invoice', '_parent_invoice.type', 'invoice_type')
def taxable_lines(self):
context = Transaction().context
lines = super().taxable_lines
- if (getattr(self, 'invoice', None)
- and getattr(self.invoice, 'type', None)):
+ if self.invoice and self.invoice.type:
invoice_type = self.invoice.type
else:
- invoice_type = getattr(self, 'invoice_type', None)
+ invoice_type = self.invoice_type
if invoice_type == 'in':
if context.get('_non_deductible'):
for line in lines:
diff -r b2ab8b67ca33 -r b8e810b49b3b modules/purchase/purchase.py
--- a/modules/purchase/purchase.py Sat Jan 17 12:53:33 2026 +0100
+++ b/modules/purchase/purchase.py Sat Jan 17 12:54:09 2026 +0100
@@ -511,6 +511,7 @@
self.total_amount = self.currency.round(self.total_amount)
@property
+ @fields.depends('lines')
def taxable_lines(self):
taxable_lines = []
# In case we're called from an on_change we have to use some sensible
diff -r b2ab8b67ca33 -r b8e810b49b3b modules/sale/sale.py
--- a/modules/sale/sale.py Sat Jan 17 12:53:33 2026 +0100
+++ b/modules/sale/sale.py Sat Jan 17 12:54:09 2026 +0100
@@ -640,6 +640,7 @@
self.total_amount = self.currency.round(self.total_amount)
@property
+ @fields.depends('lines')
def taxable_lines(self):
taxable_lines = []
for line in self.lines:
@@ -1683,19 +1684,18 @@
return progress
@property
+ @fields.depends('type', 'taxes', 'unit_price', 'quantity')
def taxable_lines(self):
- # In case we're called from an on_change
- # we have to use some sensible defaults
- if getattr(self, 'type', None) == 'line':
- return [(
- getattr(self, 'taxes', None) or [],
- getattr(self, 'unit_price', None) or Decimal(0),
- getattr(self, 'quantity', None) or 0,
+ if self.type == 'line':
+ return [(self.taxes or [],
+ self.unit_price or Decimal(0),
+ self.quantity or 0,
None,
)]
else:
return []
+ @fields.depends('sale', '_parent_sale.id')
def _get_tax_context(self):
return self.sale._get_tax_context()
diff -r b2ab8b67ca33 -r b8e810b49b3b modules/sale_point/sale.py
--- a/modules/sale_point/sale.py Sat Jan 17 12:53:33 2026 +0100
+++ b/modules/sale_point/sale.py Sat Jan 17 12:54:09 2026 +0100
@@ -441,10 +441,12 @@
return lines
@property
+ @fields.depends('lines')
def taxable_lines(self):
return sum((line.taxable_lines for line in self.lines), [])
@property
+ @fields.depends('date')
def tax_date(self):
return self.date or super().tax_date
@@ -706,6 +708,8 @@
return Product(self.product).customer_taxes_used
@property
+ @fields.depends(
+ 'taxes', 'unit_list_price', 'quantity', methods=['tax_date'])
def taxable_lines(self):
return [
(self.taxes, self.unit_list_price, self.quantity, self.tax_date)]
@@ -718,6 +722,7 @@
return 'credit_note'
@property
+ @fields.depends('sale', '_parent_sale.date')
def tax_date(self):
return self.sale.date or super().tax_date
diff -r b2ab8b67ca33 -r b8e810b49b3b modules/sale_promotion/sale.py
--- a/modules/sale_promotion/sale.py Sat Jan 17 12:53:33 2026 +0100
+++ b/modules/sale_promotion/sale.py Sat Jan 17 12:54:09 2026 +0100
@@ -161,16 +161,16 @@
return amount
@property
+ @fields.depends(
+ 'type', 'taxes', 'original_unit_price', 'unit_price', 'quantity')
def taxable_lines(self):
lines = super().taxable_lines
- if (getattr(self, 'type', None) == 'line'
+ if (self.type == 'line'
and Transaction().context.get('_original_amount')):
lines = [(
- getattr(self, 'taxes', None) or [],
- getattr(self, 'original_unit_price', None)
- or getattr(self, 'unit_price', None)
- or Decimal(0),
- getattr(self, 'quantity', None) or 0,
+ self.taxes or [],
+ self.original_unit_price or self.unit_price or Decimal(0),
+ self.quantity or 0,
None,
)]
return lines
diff -r b2ab8b67ca33 -r b8e810b49b3b modules/sale_rental/sale.py
--- a/modules/sale_rental/sale.py Sat Jan 17 12:53:33 2026 +0100
+++ b/modules/sale_rental/sale.py Sat Jan 17 12:54:09 2026 +0100
@@ -439,6 +439,7 @@
(t.amount for t in self._get_taxes().values()), Decimal(0))
@property
+ @fields.depends('lines')
def taxable_lines(self):
taxable_lines = []
for line in self.lines:
@@ -1063,17 +1064,16 @@
return {}
@property
+ @fields.depends('taxes', 'unit_price', 'quantity', 'duration_unit')
def taxable_lines(self):
- # In case we're called from an on_change
- # we have to use some sensible defaults
return [(
- getattr(self, 'taxes', None) or [],
- getattr(self, 'unit_price', None) or Decimal(0),
- (getattr(self, 'quantity', None) or 0)
- * (getattr(self, 'duration_unit', None) or 0),
+ self.taxes or [],
+ self.unit_price or Decimal(0),
+ (self.quantity or 0) * (self.duration_unit or 0),
None,
)]
+ @fields.depends('rental', '_parent_rental.id')
def _get_tax_context(self):
return self.rental._get_tax_context()