Priority to user's deafult price list over customer's default price list
This commit is contained in:
parent
f32314dd0b
commit
bc99c9d6e0
@ -78,8 +78,9 @@ class TransactionBase(StatusUpdater):
|
||||
3. Clears existing Sales Team and fetches the one mentioned in Customer
|
||||
"""
|
||||
customer_defaults = self.get_customer_defaults()
|
||||
|
||||
customer_defaults["selling_price_list"] = self.get_user_default_price_list("Selling") or \
|
||||
|
||||
customer_defaults["selling_price_list"] = \
|
||||
self.get_user_default_price_list("selling_price_list") or \
|
||||
customer_defaults.get("price_list") or \
|
||||
webnotes.conn.get_value("Customer Group", self.doc.customer_group,
|
||||
"default_price_list") or self.doc.selling_price_list
|
||||
@ -91,11 +92,11 @@ class TransactionBase(StatusUpdater):
|
||||
if self.meta.get_field("sales_team") and self.doc.customer:
|
||||
self.set_sales_team_for_customer()
|
||||
|
||||
def get_user_default_price_list(self, price_list_for):
|
||||
from webnotes.defaults import get_user_default_as_list
|
||||
user_default_price_list = get_user_default_as_list("selling_price_list"
|
||||
if price_list_for=="Selling" else "buying_price_list")
|
||||
return user_default_price_list[0] if len(user_default_price_list)==1 else ""
|
||||
def get_user_default_price_list(self, price_list):
|
||||
from webnotes.defaults import get_defaults_for
|
||||
user_default_price_list = get_defaults_for(webnotes.session.user).get(price_list)
|
||||
return cstr(user_default_price_list) \
|
||||
if not isinstance(user_default_price_list, list) else ""
|
||||
|
||||
def set_sales_team_for_customer(self):
|
||||
from webnotes.model import default_fields
|
||||
@ -128,7 +129,7 @@ class TransactionBase(StatusUpdater):
|
||||
if supplier.default_currency:
|
||||
out["currency"] = supplier.default_currency
|
||||
|
||||
out["buying_price_list"] = self.get_user_default_price_list("Buying") or \
|
||||
out["buying_price_list"] = self.get_user_default_price_list("buying_price_list") or \
|
||||
supplier.default_price_list or self.doc.buying_price_list
|
||||
|
||||
return out
|
||||
|
Loading…
Reference in New Issue
Block a user