Patches fixes (#13163)
* [fix] if serialised items not found then return * [fix] unicode encoding in patch
This commit is contained in:
parent
2550180a05
commit
2cfcbf933d
@ -7,6 +7,9 @@ import frappe
|
|||||||
def execute():
|
def execute():
|
||||||
serialised_items = [d.name for d in frappe.get_all("Item", filters={"has_serial_no": 1})]
|
serialised_items = [d.name for d in frappe.get_all("Item", filters={"has_serial_no": 1})]
|
||||||
|
|
||||||
|
if not serialised_items:
|
||||||
|
return
|
||||||
|
|
||||||
for dt in ["Stock Entry Detail", "Purchase Receipt Item", "Purchase Invoice Item"]:
|
for dt in ["Stock Entry Detail", "Purchase Receipt Item", "Purchase Invoice Item"]:
|
||||||
cond = ""
|
cond = ""
|
||||||
if dt=="Purchase Invoice Item":
|
if dt=="Purchase Invoice Item":
|
||||||
|
@ -13,22 +13,17 @@ def execute():
|
|||||||
for d in customer_group_fetch:
|
for d in customer_group_fetch:
|
||||||
when_then = []
|
when_then = []
|
||||||
for customer in batch_customers:
|
for customer in batch_customers:
|
||||||
|
value = frappe.db.escape(frappe.as_unicode(customer.get("customer_group")))
|
||||||
|
|
||||||
when_then.append('''
|
when_then.append('''
|
||||||
WHEN `{master_fieldname}` = "{docname}" and {linked_to_fieldname} != "{value}"
|
WHEN `%s` = "%s" and %s != "%s"
|
||||||
THEN "{value}"
|
THEN "%s"
|
||||||
'''.format(
|
'''%(d["master_fieldname"], frappe.db.escape(frappe.as_unicode(customer.name)),
|
||||||
master_fieldname=d["master_fieldname"],
|
d["linked_to_fieldname"], value, value))
|
||||||
linked_to_fieldname=d["linked_to_fieldname"],
|
|
||||||
docname=frappe.db.escape(frappe.as_unicode(customer.name)),
|
|
||||||
value=frappe.db.escape(frappe.as_unicode(customer.get("customer_group")))))
|
|
||||||
|
|
||||||
frappe.db.sql("""
|
frappe.db.sql("""
|
||||||
update
|
update
|
||||||
`tab{doctype}`
|
`tab%s`
|
||||||
set
|
set
|
||||||
{linked_to_fieldname} = CASE {when_then_cond} ELSE `{linked_to_fieldname}` END
|
%s = CASE %s ELSE `%s` END
|
||||||
""".format(
|
"""%(d['doctype'], d.linked_to_fieldname, " ".join(when_then), d.linked_to_fieldname))
|
||||||
doctype = d['doctype'],
|
|
||||||
when_then_cond=" ".join(when_then),
|
|
||||||
linked_to_fieldname=d.linked_to_fieldname
|
|
||||||
))
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user