mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-05 22:48:27 +00:00
[price list] Separated Default Price List for Selling and Buying and changed fieldnames
This commit is contained in:
@@ -19,7 +19,7 @@ $.extend(cur_frm.cscript, {
|
||||
},
|
||||
|
||||
show_item_prices: function() {
|
||||
var item_price = wn.model.get("Item Price", {price_list_name: cur_frm.doc.name});
|
||||
var item_price = wn.model.get("Item Price", {price_list: cur_frm.doc.name});
|
||||
|
||||
var show = item_price && item_price.length;
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import webnotes.defaults
|
||||
class DocType(DocListController):
|
||||
def onload(self):
|
||||
self.doclist.extend(webnotes.conn.sql("""select * from `tabItem Price`
|
||||
where price_list_name=%s""", self.doc.name, as_dict=True, update={"doctype": "Item Price"}))
|
||||
where price_list=%s""", self.doc.name, as_dict=True, update={"doctype": "Item Price"}))
|
||||
|
||||
def validate(self):
|
||||
if self.doc.buying_or_selling not in ["Buying", "Selling"]:
|
||||
@@ -31,10 +31,20 @@ class DocType(DocListController):
|
||||
self.validate_table_has_rows("valid_for_territories")
|
||||
|
||||
def on_update(self):
|
||||
self.set_default_if_missing()
|
||||
cart_settings = webnotes.get_obj("Shopping Cart Settings")
|
||||
if cint(cart_settings.doc.enabled):
|
||||
cart_settings.validate_price_lists()
|
||||
|
||||
def on_trash(self):
|
||||
webnotes.conn.sql("""delete from `tabItem Price` where price_list_name = %s""",
|
||||
self.doc.name)
|
||||
webnotes.conn.sql("""delete from `tabItem Price` where price_list = %s""",
|
||||
self.doc.name)
|
||||
|
||||
def set_default_if_missing(self):
|
||||
if self.doc.buying_or_selling=="Selling":
|
||||
if not webnotes.conn.get_value("Selling Settings", None, "selling_price_list"):
|
||||
webnotes.set_value("Selling Settings", "Selling Settings", "selling_price_list", self.doc.name)
|
||||
|
||||
elif self.doc.buying_or_selling=="Buying":
|
||||
if not webnotes.conn.get_value("Buying Settings", None, "buying_price_list"):
|
||||
webnotes.set_value("Buying Settings", "Buying Settings", "buying_price_list", self.doc.name)
|
||||
@@ -31,6 +31,6 @@ def get_ancestors_of(doctype, name):
|
||||
return result or []
|
||||
|
||||
@webnotes.whitelist()
|
||||
def get_price_list_currency(price_list_name):
|
||||
return {"price_list_currency": webnotes.conn.get_value("Price List", price_list_name,
|
||||
def get_price_list_currency(price_list):
|
||||
return {"price_list_currency": webnotes.conn.get_value("Price List", price_list,
|
||||
"currency")}
|
||||
Reference in New Issue
Block a user