[price list] Separated Default Price List for Selling and Buying and changed fieldnames
diff --git a/controllers/accounts_controller.py b/controllers/accounts_controller.py
index 3676510..6d4a6ad 100644
--- a/controllers/accounts_controller.py
+++ b/controllers/accounts_controller.py
@@ -55,10 +55,11 @@
def set_price_list_currency(self, buying_or_selling):
company_currency = get_company_currency(self.doc.company)
+ fieldname = buying_or_selling.lower() + "_price_list"
# TODO - change this, since price list now has only one currency allowed
- if self.meta.get_field("price_list_name") and self.doc.price_list_name and \
+ if self.meta.get_field(fieldname) and self.doc.fields.get(fieldname) and \
not self.doc.price_list_currency:
- self.doc.fields.update(get_price_list_currency(self.doc.price_list_name))
+ self.doc.fields.update(get_price_list_currency(self.doc.fields.get(fieldname)))
if self.doc.price_list_currency:
if not self.doc.plc_conversion_rate:
@@ -73,11 +74,14 @@
self.doc.currency = self.doc.price_list_currency
self.doc.conversion_rate = self.doc.plc_conversion_rate
- if self.meta.get_field("currency") and self.doc.currency != company_currency and \
- not self.doc.conversion_rate:
- exchange = self.doc.currency + "-" + company_currency
- self.doc.conversion_rate = flt(webnotes.conn.get_value("Currency Exchange",
- exchange, "exchange_rate"))
+ if self.meta.get_field("currency"):
+ if self.doc.currency != company_currency:
+ if not self.doc.conversion_rate:
+ exchange = self.doc.currency + "-" + company_currency
+ self.doc.conversion_rate = flt(webnotes.conn.get_value("Currency Exchange",
+ exchange, "exchange_rate"))
+ else:
+ self.doc.conversion_rate = 1
def set_missing_item_details(self, get_item_details):
"""set missing item values"""
diff --git a/controllers/queries.py b/controllers/queries.py
index df7b7c5..381d2c8 100644
--- a/controllers/queries.py
+++ b/controllers/queries.py
@@ -187,10 +187,10 @@
def get_price_list_currency(doctype, txt, searchfield, start, page_len, filters):
return webnotes.conn.sql("""select ref_currency from `tabItem Price`
- where price_list_name = %s and buying_or_selling = %s
+ where price_list = %s and buying_or_selling = %s
and `%s` like %s order by ref_currency asc limit %s, %s""" %
("%s", "%s", searchfield, "%s", "%s", "%s"),
- (filters["price_list_name"], filters['buying_or_selling'], "%%%s%%" % txt,
+ (filters["price_list"], filters['buying_or_selling'], "%%%s%%" % txt,
start, page_len))
def get_delivery_notes_to_be_billed(doctype, txt, searchfield, start, page_len, filters):