[price list] Separated Default Price List for Selling and Buying and changed fieldnames

This commit is contained in:
Rushabh Mehta
2013-08-09 18:11:35 +05:30
parent 0b9954059c
commit 4a404e9299
36 changed files with 234 additions and 201 deletions

View File

@@ -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;

View File

@@ -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)

View File

@@ -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")}