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
This commit is contained in:
Cédric Krier
2023-02-17 12:07:43 +01:00
parent c17cf5243f
commit a0c723970f
2 changed files with 6 additions and 6 deletions
+4 -4
View File
@@ -52,7 +52,7 @@ class Sale(IdentifierMixin, metaclass=PoolMeta):
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,10 +74,10 @@ class Sale(IdentifierMixin, metaclass=PoolMeta):
('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)
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 @@ class Line(IdentifierMixin, metaclass=PoolMeta):
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:
+2 -2
View File
@@ -324,12 +324,12 @@ class Shop(metaclass=PoolMeta):
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):
if not hasattr(template, 'images'):
if not getattr(template, 'images', None):
return
transaction = Transaction()
image_ids = set()