Cédric Krier pushed to branch branch/default at Tryton / Tryton


Commits:
f0c5a67b by Cédric Krier at 2023-02-17T12:07:43+01:00
Test if Shopify attribute is not empty before using it

Shopify seems to have changed from not setting empty attributes to setting
them empty.

Closes #12097
- - - - -


2 changed files:

- modules/web_shop_shopify/sale.py
- modules/web_shop_shopify/web.py


Changes:

=====================================
modules/web_shop_shopify/sale.py
=====================================
@@ -52,7 +52,7 @@
         Currency = pool.get('currency.currency')
         Line = pool.get('sale.line')
 
-        if hasattr(order, 'customer'):
+        if getattr(order, 'customer', None):
             party = Party.get_from_shopify(shop, order.customer)
             party.save()
             party.set_shopify_identifier(shop, order.customer.id)
@@ -74,6 +74,6 @@
                     ('code', '=', order.currency),
                     ], limit=1)
 
-        if hasattr(order, 'shipping_address'):
+        if getattr(order, 'shipping_address', None):
             sale.shipment_address = party.get_address_from_shopify(
                 order.shipping_address)
@@ -78,6 +78,6 @@
             sale.shipment_address = party.get_address_from_shopify(
                 order.shipping_address)
-        if hasattr(order, 'billing_address'):
+        if getattr(order, 'billing_address', None):
             sale.invoice_address = party.get_address_from_shopify(
                 order.billing_address)
 
@@ -337,7 +337,7 @@
             line.sale = sale
             line.shopify_identifier = line_item.id
         assert line.shopify_identifier == line_item.id
-        if hasattr(line_item, 'variant_id'):
+        if getattr(line_item, 'variant_id', None):
             line.product = Product.search_shopify_identifier(
                 sale.web_shop, line_item.variant_id)
         else:


=====================================
modules/web_shop_shopify/web.py
=====================================
@@ -324,8 +324,8 @@
         template.set_shopify_identifier(self)
         for product in template.products:
             product.set_shopify_identifier(self)
-        if hasattr(template, 'images'):
+        if getattr(template, 'images', None):
             for image in template.images:
                 image.set_shopify_identifier(self)
 
     def __shopify_update_images(self, template, shopify_product):
@@ -328,8 +328,8 @@
             for image in template.images:
                 image.set_shopify_identifier(self)
 
     def __shopify_update_images(self, template, shopify_product):
-        if not hasattr(template, 'images'):
+        if not getattr(template, 'images', None):
             return
         transaction = Transaction()
         image_ids = set()



View it on Heptapod: 
https://foss.heptapod.net/tryton/tryton/-/commit/f0c5a67b3ca9438837f0cf865f860e0aaf814bcf

-- 
View it on Heptapod: 
https://foss.heptapod.net/tryton/tryton/-/commit/f0c5a67b3ca9438837f0cf865f860e0aaf814bcf
You're receiving this email because of your account on foss.heptapod.net.


Reply via email to