Fixes for model-cleanup frappe/frappe#478
This commit is contained in:
parent
f7daab7393
commit
13ae548ff6
@ -63,6 +63,9 @@ def set_contact_details(out, party, party_type):
|
||||
out.contact_person = frappe.db.get_value("Contact",
|
||||
{party_type.lower(): party.name, "is_primary_contact":1}, "name")
|
||||
|
||||
if not out.contact_person:
|
||||
return
|
||||
|
||||
out.update(get_contact_details(out.contact_person))
|
||||
|
||||
def set_other_values(out, party, party_type):
|
||||
|
@ -44,6 +44,9 @@ def import_country_and_currency():
|
||||
|
||||
def import_defaults():
|
||||
records = [
|
||||
# role
|
||||
{'doctype': "Role", "role_name": "Analytics"},
|
||||
|
||||
# item group
|
||||
{'doctype': 'Item Group', 'item_group_name': 'All Item Groups', 'is_group': 'Yes', 'parent_item_group': ''},
|
||||
{'doctype': 'Item Group', 'item_group_name': 'Products', 'is_group': 'No', 'parent_item_group': 'All Item Groups'},
|
||||
|
@ -80,7 +80,6 @@ def create_fiscal_year_and_company(args):
|
||||
'year_end_date': args.get('fy_end_date'),
|
||||
}).insert()
|
||||
|
||||
print args
|
||||
# Company
|
||||
frappe.get_doc({
|
||||
"doctype":"Company",
|
||||
@ -103,9 +102,9 @@ def create_price_lists(args):
|
||||
"buying": 1 if pl_type == "Buying" else 0,
|
||||
"selling": 1 if pl_type == "Selling" else 0,
|
||||
"currency": args["currency"],
|
||||
"valid_for_territories": {
|
||||
"valid_for_territories": [{
|
||||
"territory": "All Territories"
|
||||
}
|
||||
}]
|
||||
}).insert()
|
||||
|
||||
def set_defaults(args):
|
||||
|
@ -13,7 +13,10 @@ class PriceList(DocListController):
|
||||
if not cint(self.buying) and not cint(self.selling):
|
||||
throw(_("Price List must be applicable for Buying or Selling"))
|
||||
|
||||
if not self.get("valid_for_territories"):
|
||||
try:
|
||||
# at least one territory
|
||||
self.validate_table_has_rows("valid_for_territories")
|
||||
except frappe.EmptyTableError:
|
||||
# if no territory, set default territory
|
||||
if frappe.defaults.get_user_default("territory"):
|
||||
self.append("valid_for_territories", {
|
||||
@ -21,8 +24,7 @@ class PriceList(DocListController):
|
||||
"territory": frappe.defaults.get_user_default("territory")
|
||||
})
|
||||
else:
|
||||
# at least one territory
|
||||
self.validate_table_has_rows("valid_for_territories")
|
||||
raise
|
||||
|
||||
def on_update(self):
|
||||
self.set_default_if_missing()
|
||||
|
Loading…
x
Reference in New Issue
Block a user