changeset 23a02cf1a588 in modules/account_tax_rule_country:5.0
details: 
https://hg.tryton.org/modules/account_tax_rule_country?cmd=changeset&node=23a02cf1a588
description:
        Do not fail if sale or purchase are not activated

        issue10246
        review341911002
        (grafted from d03efe83669bfdeea59dccd4797a96a1bc740309)
diffstat:

 account.py |  14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diffs (31 lines):

diff -r 5f6abf4fcf25 -r 23a02cf1a588 account.py
--- a/account.py        Sat Apr 04 17:49:53 2020 +0200
+++ b/account.py        Sat Apr 10 14:02:31 2021 +0200
@@ -40,17 +40,23 @@
     @fields.depends('origin')
     def _get_tax_rule_pattern(self):
         pool = Pool()
-        SaleLine = pool.get('sale.line')
-        PurchaseLine = pool.get('purchase.line')
+        try:
+            SaleLine = pool.get('sale.line')
+        except KeyError:
+            SaleLine = None
+        try:
+            PurchaseLine = pool.get('purchase.line')
+        except KeyError:
+            PurchaseLine = None
 
         pattern = super(InvoiceLine, self)._get_tax_rule_pattern()
 
         from_country, to_country = None, None
-        if isinstance(self.origin, SaleLine):
+        if SaleLine and isinstance(self.origin, SaleLine):
             if self.origin.warehouse.address:
                 from_country = self.origin.warehouse.address.country
             to_country = self.origin.sale.shipment_address.country
-        elif isinstance(self.origin, PurchaseLine):
+        elif PurchaseLine and isinstance(self.origin, PurchaseLine):
             from_country = self.origin.purchase.invoice_address.country
             if self.origin.purchase.warehouse.address:
                 to_country = self.origin.purchase.warehouse.address.country

Reply via email to