fix: Unlink PO on cancelling SO

This commit is contained in:
GangaManoj 2021-09-20 19:01:46 +05:30
parent 41678faeee
commit e77534fe13

View File

@ -837,11 +837,16 @@ class AccountsController(TransactionBase):
print("Before unlinking: ", linked_po) print("Before unlinking: ", linked_po)
if linked_po: if linked_po:
frappe.db.sql("""update `tabPurchase Order Item` frappe.db.set_value(
set sales_order = null, sales_order_item = null, 'Purchase Order Item', {
modified = %s, modified_by = %s 'sales_order': self.name,
where sales_order = %s and sales_order_item in %s 'sales_order_item': ['in', so_items],
and docstatus < 2""", (now(), frappe.session.user, self.name, so_items)) 'docstatus': ['<', 2]
},{
'sales_order': None,
'sales_order_item': None
}
)
frappe.msgprint(_("Purchase Orders {0} are un-linked").format("\n".join(linked_po))) frappe.msgprint(_("Purchase Orders {0} are un-linked").format("\n".join(linked_po)))