Fixes for model-cleanup frappe/frappe#478

This commit is contained in:
Anand Doshi 2014-04-10 18:40:57 +05:30
parent f7daab7393
commit 13ae548ff6
7 changed files with 221 additions and 214 deletions

View File

@ -63,6 +63,9 @@ def set_contact_details(out, party, party_type):
out.contact_person = frappe.db.get_value("Contact", out.contact_person = frappe.db.get_value("Contact",
{party_type.lower(): party.name, "is_primary_contact":1}, "name") {party_type.lower(): party.name, "is_primary_contact":1}, "name")
if not out.contact_person:
return
out.update(get_contact_details(out.contact_person)) out.update(get_contact_details(out.contact_person))
def set_other_values(out, party, party_type): def set_other_values(out, party, party_type):

View File

@ -44,6 +44,9 @@ def import_country_and_currency():
def import_defaults(): def import_defaults():
records = [ records = [
# role
{'doctype': "Role", "role_name": "Analytics"},
# item group # item group
{'doctype': 'Item Group', 'item_group_name': 'All Item Groups', 'is_group': 'Yes', 'parent_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'}, {'doctype': 'Item Group', 'item_group_name': 'Products', 'is_group': 'No', 'parent_item_group': 'All Item Groups'},

View File

@ -80,7 +80,6 @@ def create_fiscal_year_and_company(args):
'year_end_date': args.get('fy_end_date'), 'year_end_date': args.get('fy_end_date'),
}).insert() }).insert()
print args
# Company # Company
frappe.get_doc({ frappe.get_doc({
"doctype":"Company", "doctype":"Company",
@ -103,9 +102,9 @@ def create_price_lists(args):
"buying": 1 if pl_type == "Buying" else 0, "buying": 1 if pl_type == "Buying" else 0,
"selling": 1 if pl_type == "Selling" else 0, "selling": 1 if pl_type == "Selling" else 0,
"currency": args["currency"], "currency": args["currency"],
"valid_for_territories": { "valid_for_territories": [{
"territory": "All Territories" "territory": "All Territories"
} }]
}).insert() }).insert()
def set_defaults(args): def set_defaults(args):

View File

@ -13,7 +13,10 @@ class PriceList(DocListController):
if not cint(self.buying) and not cint(self.selling): if not cint(self.buying) and not cint(self.selling):
throw(_("Price List must be applicable for Buying or 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 no territory, set default territory
if frappe.defaults.get_user_default("territory"): if frappe.defaults.get_user_default("territory"):
self.append("valid_for_territories", { self.append("valid_for_territories", {
@ -21,8 +24,7 @@ class PriceList(DocListController):
"territory": frappe.defaults.get_user_default("territory") "territory": frappe.defaults.get_user_default("territory")
}) })
else: else:
# at least one territory raise
self.validate_table_has_rows("valid_for_territories")
def on_update(self): def on_update(self):
self.set_default_if_missing() self.set_default_if_missing()