fix: return null for attribute (#20674)

This commit is contained in:
Mangesh-Khairnar 2020-02-20 12:58:54 +05:30 committed by GitHub
parent 6071313965
commit 6f6e3a940b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 4 deletions

View File

@ -165,6 +165,9 @@ def create_item_code(amazon_item_json, sku):
return item.name
def create_manufacturer(amazon_item_json):
if not amazon_item_json.Product.AttributeSets.ItemAttributes.Manufacturer:
return None
existing_manufacturer = frappe.db.get_value("Manufacturer",
filters={"short_name":amazon_item_json.Product.AttributeSets.ItemAttributes.Manufacturer})
@ -177,6 +180,9 @@ def create_manufacturer(amazon_item_json):
return existing_manufacturer
def create_brand(amazon_item_json):
if not amazon_item_json.Product.AttributeSets.ItemAttributes.Brand:
return None
existing_brand = frappe.db.get_value("Brand",
filters={"brand":amazon_item_json.Product.AttributeSets.ItemAttributes.Brand})
if not existing_brand:

View File

@ -7,7 +7,6 @@ import frappe
from frappe.model.document import Document
import dateutil
from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
from erpnext.erpnext_integrations.doctype.amazon_mws_settings.amazon_methods import get_products_details, get_orders
class AmazonMWSSettings(Document):
def validate(self):
@ -19,12 +18,12 @@ class AmazonMWSSettings(Document):
def get_products_details(self):
if self.enable_amazon == 1:
get_products_details()
frappe.enqueue('erpnext.erpnext_integrations.doctype.amazon_mws_settings.amazon_methods.get_products_details')
def get_order_details(self):
if self.enable_amazon == 1:
after_date = dateutil.parser.parse(self.after_date).strftime("%Y-%m-%d")
get_orders(after_date = after_date)
frappe.enqueue('erpnext.erpnext_integrations.doctype.amazon_mws_settings.amazon_methods.get_orders', after_date=after_date)
def schedule_get_order_details():
mws_settings = frappe.get_doc("Amazon MWS Settings")

View File

@ -33,7 +33,10 @@ class object_dict(dict):
def __getattr__(self, item):
d = self.__getitem__(item)
try:
d = self.__getitem__(item)
except KeyError:
return None
if isinstance(d, dict) and 'value' in d and len(d) == 1:
return d['value']