diff --git a/patches/april_2013/p08_price_list_country.py b/patches/april_2013/p08_price_list_country.py index 1179e1da5b..65643cc239 100644 --- a/patches/april_2013/p08_price_list_country.py +++ b/patches/april_2013/p08_price_list_country.py @@ -1,4 +1,5 @@ import webnotes def execute(): + webnotes.reload_doc("Setup", "DocType", "Price List") webnotes.conn.sql("""update `tabPrice List` set valid_for_all_countries=1""") \ No newline at end of file diff --git a/setup/doctype/price_list/price_list.js b/setup/doctype/price_list/price_list.js index 0020edaf20..b68627f73f 100644 --- a/setup/doctype/price_list/price_list.js +++ b/setup/doctype/price_list/price_list.js @@ -29,9 +29,14 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) { } cur_frm.cscript.show_item_prices = function() { - cur_frm.toggle_display("item_prices_section", cur_frm.doc.__item_price && cur_frm.doc.__item_price.length); + var item_price = wn.model.get("Item Price", {price_list_name: cur_frm.doc.name}); + + var show = item_price && item_price.length; + + cur_frm.toggle_display("item_prices_section", show); $(cur_frm.fields_dict.item_prices.wrapper).empty(); - if (!cur_frm.doc.__item_price) return; + if (!show) return; + var out = '
' + wn._("Item Code") + ' | \ @@ -40,7 +45,7 @@ cur_frm.cscript.show_item_prices = function() {' + wn._("Valid For Buying") + ' | \
---|---|
' + d.parent + ' | ' + '' + format_currency(d.ref_rate, d.ref_currency) + ' | ' diff --git a/setup/doctype/price_list/price_list.py b/setup/doctype/price_list/price_list.py index 9fef9154d7..ae49bf868d 100644 --- a/setup/doctype/price_list/price_list.py +++ b/setup/doctype/price_list/price_list.py @@ -25,8 +25,8 @@ class DocType: self.doc, self.doclist = d, dl def onload(self): - self.doc.fields["__item_price"] = webnotes.conn.sql("""select parent, ref_rate, ref_currency, selling, buying - from `tabItem Price` where price_list_name=%s""", self.doc.name, as_dict=True) + 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"})) def validate(self): if not (cint(self.doc.valid_for_all_countries) or len(self.doclist.get({"parentfield": "valid_for_countries"}))):