[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 import msgprint, _
|
||||||
from webnotes.utils import comma_or, cint
|
from webnotes.utils import comma_or, cint
|
||||||
from webnotes.model.controller import DocListController
|
from webnotes.model.controller import DocListController
|
||||||
|
import webnotes.defaults
|
||||||
|
|
||||||
class DocType(DocListController):
|
class DocType(DocListController):
|
||||||
def onload(self):
|
def onload(self):
|
||||||
@ -30,6 +31,15 @@ class DocType(DocListController):
|
|||||||
msgprint(_(self.meta.get_label("buying_or_selling")) + " " + _("must be one of") + " " +
|
msgprint(_(self.meta.get_label("buying_or_selling")) + " " + _("must be one of") + " " +
|
||||||
comma_or(["Buying", "Selling"]), raise_exception=True)
|
comma_or(["Buying", "Selling"]), raise_exception=True)
|
||||||
|
|
||||||
|
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
|
# at least one territory
|
||||||
self.validate_table_has_rows("valid_for_territories")
|
self.validate_table_has_rows("valid_for_territories")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user