[fix] if no valid territory for price list, try adding the user's default territory
This commit is contained in:
parent
482f34302e
commit
49154c790e
@ -19,6 +19,7 @@ import webnotes
|
||||
from webnotes import msgprint, _
|
||||
from webnotes.utils import comma_or, cint
|
||||
from webnotes.model.controller import DocListController
|
||||
import webnotes.defaults
|
||||
|
||||
class DocType(DocListController):
|
||||
def onload(self):
|
||||
@ -30,8 +31,17 @@ class DocType(DocListController):
|
||||
msgprint(_(self.meta.get_label("buying_or_selling")) + " " + _("must be one of") + " " +
|
||||
comma_or(["Buying", "Selling"]), raise_exception=True)
|
||||
|
||||
# at least one territory
|
||||
self.validate_table_has_rows("valid_for_territories")
|
||||
if not self.doclist.get({"parentfield": "valid_for_territories"}):
|
||||
# if no territory, set default territory
|
||||
if webnotes.defaults.get_user_default("territory"):
|
||||
self.doclist.append({
|
||||
"doctype": "For Territory",
|
||||
"parentfield": "valid_for_territories",
|
||||
"territory": webnotes.defaults.get_user_default("territory")
|
||||
})
|
||||
else:
|
||||
# at least one territory
|
||||
self.validate_table_has_rows("valid_for_territories")
|
||||
|
||||
def on_update(self):
|
||||
cart_settings = webnotes.get_obj("Shopping Cart Settings")
|
||||
|
Loading…
x
Reference in New Issue
Block a user