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:
@@ -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:
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user