changeset af3c31e24bfa in modules/account_tax_rule_country:5.0 details: https://hg.tryton.org/modules/account_tax_rule_country?cmd=changeset&node=af3c31e24bfa description: Test origin has positive id before using it
issue10186 review359551002 (grafted from 3c57ca86838ca7daed3784a45906f0637c24bfef) diffstat: account.py | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diffs (21 lines): diff -r 41380dbdf3fb -r af3c31e24bfa account.py --- a/account.py Wed May 05 22:53:46 2021 +0200 +++ b/account.py Fri Apr 23 20:33:03 2021 +0200 @@ -52,11 +52,15 @@ pattern = super(InvoiceLine, self)._get_tax_rule_pattern() from_country, to_country = None, None - if SaleLine and isinstance(self.origin, SaleLine): + if (SaleLine + and isinstance(self.origin, SaleLine) + and self.origin.id >= 0): if self.origin.warehouse.address: from_country = self.origin.warehouse.address.country to_country = self.origin.sale.shipment_address.country - elif PurchaseLine and isinstance(self.origin, PurchaseLine): + elif (PurchaseLine + and isinstance(self.origin, PurchaseLine) + and self.origin.id >= 0): from_country = self.origin.purchase.invoice_address.country if self.origin.purchase.warehouse.address: to_country = self.origin.purchase.warehouse.address.country