From 36a4db69b8e9a844def3db0c13a34f9c64f3def4 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 18 Feb 2014 15:14:46 +0530 Subject: [PATCH] price list on_trash function --- erpnext/stock/doctype/price_list/price_list.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/erpnext/stock/doctype/price_list/price_list.py b/erpnext/stock/doctype/price_list/price_list.py index 5c383f8db9..936d868532 100644 --- a/erpnext/stock/doctype/price_list/price_list.py +++ b/erpnext/stock/doctype/price_list/price_list.py @@ -3,7 +3,7 @@ from __future__ import unicode_literals import frappe -from frappe import msgprint, _, throw +from frappe import _, throw from frappe.utils import cint from frappe.model.controller import DocListController import frappe.defaults @@ -42,3 +42,15 @@ class DocType(DocListController): frappe.conn.sql("""update `tabItem Price` set currency=%s, buying=%s, selling=%s, modified=NOW() where price_list=%s""", (self.doc.currency, cint(self.doc.buying), cint(self.doc.selling), self.doc.name)) + + def on_trash(self): + def _update_default_price_list(module): + b = frappe.bean(module + " Settings") + price_list_fieldname = module.lower() + "_price_list" + + if self.doc.name == b.doc.fields[price_list_fieldname]: + b.doc.fields[price_list_fieldname] = None + b.save() + + for module in ["Selling", "Buying"]: + _update_default_price_list(module) \ No newline at end of file