conditional check for single docs (#5060)

This commit is contained in:
Achilles Rasquinha 2018-02-22 18:05:38 +05:30 committed by Nabin Hait
parent a56fe9a8fb
commit c2fb0c3bde

View file

@ -400,21 +400,22 @@ def update_linked_doctypes(parent, child, name, value):
product_list = list_combinatrix(parent_list, child_list)
for d in product_list:
frappe.db.sql("""
update
`tab{doctype}`
set
{fieldname} = "{value}"
where
{parent_fieldname} = "{docname}"
and {fieldname} != "{value}"
""".format(
doctype = d['parent']['parent'],
fieldname = d['child']['fieldname'],
parent_fieldname = d['parent']['fieldname'],
value = value,
docname = name
))
if not d['parent']['issingle']:
frappe.db.sql("""
update
`tab{doctype}`
set
{fieldname} = "{value}"
where
{parent_fieldname} = "{docname}"
and {fieldname} != "{value}"
""".format(
doctype = d['parent']['parent'],
fieldname = d['child']['fieldname'],
parent_fieldname = d['parent']['fieldname'],
value = frappe.db.escape(value),
docname = frappe.db.escape(name)
))
def list_combinatrix(dict1, dict2):
""" form all possible products with the given lists elements """