details: https://code.tryton.org/tryton/commit/e97af2f1eb23
branch: default
user: Maxime Richez <[email protected]>
date: Wed Mar 18 12:01:17 2026 +0100
description:
Use the first non-invoice line origin to calculate tax pattern for
countries
Closes #14388
diffstat:
modules/account_tax_rule_country/account.py | 26 +++++++++++++++-----------
1 files changed, 15 insertions(+), 11 deletions(-)
diffs (49 lines):
diff -r 3bdcec9b622c -r e97af2f1eb23 modules/account_tax_rule_country/account.py
--- a/modules/account_tax_rule_country/account.py Wed Mar 11 12:51:12
2026 +0100
+++ b/modules/account_tax_rule_country/account.py Wed Mar 18 12:01:17
2026 +0100
@@ -124,30 +124,34 @@
pattern = super()._get_tax_rule_pattern()
from_country = from_subdivision = to_country = to_subdivision = None
+ origin = self.origin
+ # find the first origin which is not an invoice line
+ while isinstance(origin, self.__class__) and origin.id >= 0:
+ origin = origin.origin
if (SaleLine
- and isinstance(self.origin, SaleLine)
- and self.origin.id >= 0):
- warehouse = self.origin.warehouse
+ and isinstance(origin, SaleLine)
+ and origin.id >= 0):
+ warehouse = origin.warehouse
if warehouse and warehouse.address:
from_country = warehouse.address.country
from_subdivision = warehouse.address.subdivision
- shipment_address = self.origin.sale.shipment_address
+ shipment_address = origin.sale.shipment_address
to_country = shipment_address.country
to_subdivision = shipment_address.subdivision
elif (PurchaseLine
- and isinstance(self.origin, PurchaseLine)
- and self.origin.id >= 0):
- invoice_address = self.origin.purchase.invoice_address
+ and isinstance(origin, PurchaseLine)
+ and origin.id >= 0):
+ invoice_address = origin.purchase.invoice_address
from_country = invoice_address.country
from_subdivision = invoice_address.subdivision
- warehouse = self.origin.warehouse
+ warehouse = origin.warehouse
if warehouse and warehouse.address:
to_country = warehouse.address.country
to_subdivision = warehouse.address.subdivision
elif (Move
- and isinstance(self.origin, Move)
- and self.origin.id >= 0):
- move = self.origin
+ and isinstance(origin, Move)
+ and origin.id >= 0):
+ move = origin
if move.from_location.warehouse:
warehouse_address = move.from_location.warehouse.address
if warehouse_address: