style: Clean up code formatting

This commit is contained in:
Kevin Chan 2020-11-03 10:57:52 +08:00
parent 312561fd77
commit a2ba8ea74a

View File

@ -46,12 +46,7 @@ class ItemPrice(Document):
self.item_name, self.item_description = frappe.db.get_value("Item", self.item_code,["item_name", "description"]) self.item_name, self.item_description = frappe.db.get_value("Item", self.item_code,["item_name", "description"])
def check_duplicates(self): def check_duplicates(self):
conditions = """ conditions = """where item_code = %(item_code)s and price_list = %(price_list)s and name != %(name)s"""
where
item_code = %(item_code)s
and price_list = %(price_list)s
and name != %(name)s
"""
for field in [ for field in [
"uom", "uom",
@ -59,23 +54,18 @@ class ItemPrice(Document):
"valid_upto", "valid_upto",
"packing_unit", "packing_unit",
"customer", "customer",
"supplier", "supplier",]:
]:
if self.get(field): if self.get(field):
conditions += " and {0} = %({0})s ".format(field) conditions += " and {0} = %({0})s ".format(field)
else: else:
conditions += "and (isnull({0}) or {0} = '')".format(field) conditions += "and (isnull({0}) or {0} = '')".format(field)
price_list_rate = frappe.db.sql( price_list_rate = frappe.db.sql("""
"""
select price_list_rate select price_list_rate
from `tabItem Price` from `tabItem Price`
{conditions} {conditions}
""".format( """.format(conditions=conditions),
conditions=conditions self.as_dict(),)
),
self.as_dict(),
)
if price_list_rate: if price_list_rate:
frappe.throw(_("Item Price appears multiple times based on Price List, Supplier/Customer, Currency, Item, UOM, Qty, and Dates."), ItemPriceDuplicateItem,) frappe.throw(_("Item Price appears multiple times based on Price List, Supplier/Customer, Currency, Item, UOM, Qty, and Dates."), ItemPriceDuplicateItem,)