fix: return null for attribute (#20674)
This commit is contained in:
parent
6071313965
commit
6f6e3a940b
@ -165,6 +165,9 @@ def create_item_code(amazon_item_json, sku):
|
|||||||
return item.name
|
return item.name
|
||||||
|
|
||||||
def create_manufacturer(amazon_item_json):
|
def create_manufacturer(amazon_item_json):
|
||||||
|
if not amazon_item_json.Product.AttributeSets.ItemAttributes.Manufacturer:
|
||||||
|
return None
|
||||||
|
|
||||||
existing_manufacturer = frappe.db.get_value("Manufacturer",
|
existing_manufacturer = frappe.db.get_value("Manufacturer",
|
||||||
filters={"short_name":amazon_item_json.Product.AttributeSets.ItemAttributes.Manufacturer})
|
filters={"short_name":amazon_item_json.Product.AttributeSets.ItemAttributes.Manufacturer})
|
||||||
|
|
||||||
@ -177,6 +180,9 @@ def create_manufacturer(amazon_item_json):
|
|||||||
return existing_manufacturer
|
return existing_manufacturer
|
||||||
|
|
||||||
def create_brand(amazon_item_json):
|
def create_brand(amazon_item_json):
|
||||||
|
if not amazon_item_json.Product.AttributeSets.ItemAttributes.Brand:
|
||||||
|
return None
|
||||||
|
|
||||||
existing_brand = frappe.db.get_value("Brand",
|
existing_brand = frappe.db.get_value("Brand",
|
||||||
filters={"brand":amazon_item_json.Product.AttributeSets.ItemAttributes.Brand})
|
filters={"brand":amazon_item_json.Product.AttributeSets.ItemAttributes.Brand})
|
||||||
if not existing_brand:
|
if not existing_brand:
|
||||||
|
@ -7,7 +7,6 @@ import frappe
|
|||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
import dateutil
|
import dateutil
|
||||||
from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
|
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):
|
class AmazonMWSSettings(Document):
|
||||||
def validate(self):
|
def validate(self):
|
||||||
@ -19,12 +18,12 @@ class AmazonMWSSettings(Document):
|
|||||||
|
|
||||||
def get_products_details(self):
|
def get_products_details(self):
|
||||||
if self.enable_amazon == 1:
|
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):
|
def get_order_details(self):
|
||||||
if self.enable_amazon == 1:
|
if self.enable_amazon == 1:
|
||||||
after_date = dateutil.parser.parse(self.after_date).strftime("%Y-%m-%d")
|
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():
|
def schedule_get_order_details():
|
||||||
mws_settings = frappe.get_doc("Amazon MWS Settings")
|
mws_settings = frappe.get_doc("Amazon MWS Settings")
|
||||||
|
@ -33,7 +33,10 @@ class object_dict(dict):
|
|||||||
|
|
||||||
def __getattr__(self, item):
|
def __getattr__(self, item):
|
||||||
|
|
||||||
|
try:
|
||||||
d = self.__getitem__(item)
|
d = self.__getitem__(item)
|
||||||
|
except KeyError:
|
||||||
|
return None
|
||||||
|
|
||||||
if isinstance(d, dict) and 'value' in d and len(d) == 1:
|
if isinstance(d, dict) and 'value' in d and len(d) == 1:
|
||||||
return d['value']
|
return d['value']
|
||||||
|
Loading…
Reference in New Issue
Block a user