started party frappe/erpnext#1503
diff --git a/erpnext/accounts/doctype/cost_center/cost_center.py b/erpnext/accounts/doctype/cost_center/cost_center.py
index 7013ffb..d79bbcc 100644
--- a/erpnext/accounts/doctype/cost_center/cost_center.py
+++ b/erpnext/accounts/doctype/cost_center/cost_center.py
@@ -6,9 +6,9 @@
from frappe import msgprint, _
-from frappe.utils.nestedset import DocTypeNestedSet
+from frappe.utils.nestedset import NestedSet
-class CostCenter(DocTypeNestedSet):
+class CostCenter(NestedSet):
nsm_parent_field = 'parent_cost_center'
def autoname(self):
diff --git a/erpnext/accounts/doctype/journal_voucher/journal_voucher.js b/erpnext/accounts/doctype/journal_voucher/journal_voucher.js
index e8e513d..b1aa70b 100644
--- a/erpnext/accounts/doctype/journal_voucher/journal_voucher.js
+++ b/erpnext/accounts/doctype/journal_voucher/journal_voucher.js
@@ -8,22 +8,22 @@
this.load_defaults();
this.setup_queries();
},
-
+
load_defaults: function() {
if(this.frm.doc.__islocal && this.frm.doc.company) {
frappe.model.set_default_values(this.frm.doc);
- $.each(this.frm.doc.entries, function(i, jvd) {
+ $.each(this.frm.doc.entries || [], function(i, jvd) {
frappe.model.set_default_values(jvd);
}
);
-
+
if(!this.frm.doc.amended_from) this.frm.doc.posting_date = get_today();
}
},
-
+
setup_queries: function() {
var me = this;
-
+
$.each(["account", "cost_center"], function(i, fieldname) {
me.frm.set_query(fieldname, "entries", function() {
frappe.model.validate_missing(me.frm.doc, "company");
@@ -35,8 +35,8 @@
};
});
});
-
- $.each([["against_voucher", "Purchase Invoice", "credit_to"],
+
+ $.each([["against_voucher", "Purchase Invoice", "credit_to"],
["against_invoice", "Sales Invoice", "debit_to"]], function(i, opts) {
me.frm.set_query(opts[0], "entries", function(doc, cdt, cdn) {
var jvd = frappe.get_doc(cdt, cdn);
@@ -50,49 +50,49 @@
};
});
});
-
+
this.frm.set_query("against_jv", "entries", function(doc, cdt, cdn) {
var jvd = frappe.get_doc(cdt, cdn);
frappe.model.validate_missing(jvd, "account");
-
+
return {
query: "accounts.doctype.journal_voucher.journal_voucher.get_against_jv",
filters: { account: jvd.account }
};
});
},
-
+
against_voucher: function(doc, cdt, cdn) {
var d = frappe.get_doc(cdt, cdn);
if (d.against_voucher && !flt(d.debit)) {
this.get_outstanding({
- 'doctype': 'Purchase Invoice',
+ 'doctype': 'Purchase Invoice',
'docname': d.against_voucher
}, d)
}
},
-
+
against_invoice: function(doc, cdt, cdn) {
var d = frappe.get_doc(cdt, cdn);
if (d.against_invoice && !flt(d.credit)) {
this.get_outstanding({
- 'doctype': 'Sales Invoice',
+ 'doctype': 'Sales Invoice',
'docname': d.against_invoice
}, d)
}
},
-
+
against_jv: function(doc, cdt, cdn) {
var d = frappe.get_doc(cdt, cdn);
if (d.against_jv && !flt(d.credit) && !flt(d.debit)) {
this.get_outstanding({
- 'doctype': 'Journal Voucher',
+ 'doctype': 'Journal Voucher',
'docname': d.against_jv,
'account': d.account
}, d)
}
},
-
+
get_outstanding: function(args, child) {
var me = this;
return this.frm.call({
@@ -104,7 +104,7 @@
}
});
}
-
+
});
cur_frm.script_manager.make(erpnext.accounts.JournalVoucher);
@@ -113,7 +113,7 @@
cur_frm.cscript.is_opening(doc)
erpnext.hide_naming_series();
cur_frm.cscript.voucher_type(doc);
- if(doc.docstatus==1) {
+ if(doc.docstatus==1) {
cur_frm.appframe.add_button(frappe._('View Ledger'), function() {
frappe.route_options = {
"voucher_no": doc.name,
@@ -154,7 +154,7 @@
cur_frm.cscript.credit = function(doc,dt,dn) { cur_frm.cscript.update_totals(doc); }
cur_frm.cscript.get_balance = function(doc,dt,dn) {
- cur_frm.cscript.update_totals(doc);
+ cur_frm.cscript.update_totals(doc);
return $c_obj(cur_frm.doc, 'get_balance', '', function(r, rt){
cur_frm.refresh();
});
@@ -174,7 +174,7 @@
}
});
}
-}
+}
cur_frm.cscript.validate = function(doc,cdt,cdn) {
cur_frm.cscript.update_totals(doc);
@@ -195,7 +195,7 @@
if((doc.entries || []).length!==0 || !doc.company) // too early
return;
-
+
var update_jv_details = function(doc, r) {
$.each(r.message, function(i, d) {
var jvdetail = frappe.model.add_child(doc, "Journal Voucher Detail", "entries");
@@ -204,7 +204,7 @@
});
refresh_field("entries");
}
-
+
if(in_list(["Bank Voucher", "Cash Voucher"], doc.voucher_type)) {
return frappe.call({
type: "GET",
@@ -227,7 +227,7 @@
"company": doc.company
},
callback: function(r) {
- frappe.model.clear_table("Journal Voucher Detail", "Journal Voucher",
+ frappe.model.clear_table("Journal Voucher Detail", "Journal Voucher",
doc.name, "entries");
if(r.message) {
update_jv_details(doc, r);
@@ -236,4 +236,4 @@
}
})
}
-}
\ No newline at end of file
+}
diff --git a/erpnext/contacts/__init__.py b/erpnext/contacts/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/contacts/__init__.py
diff --git a/erpnext/contacts/doctype/__init__.py b/erpnext/contacts/doctype/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/contacts/doctype/__init__.py
diff --git a/erpnext/contacts/doctype/party_type/__init__.py b/erpnext/contacts/doctype/party_type/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/contacts/doctype/party_type/__init__.py
diff --git a/erpnext/contacts/doctype/party_type/party_type.json b/erpnext/contacts/doctype/party_type/party_type.json
new file mode 100644
index 0000000..b667b6e
--- /dev/null
+++ b/erpnext/contacts/doctype/party_type/party_type.json
@@ -0,0 +1,302 @@
+{
+ "_last_update": null,
+ "_user_tags": null,
+ "allow_attach": null,
+ "allow_copy": null,
+ "allow_email": null,
+ "allow_import": null,
+ "allow_print": null,
+ "allow_rename": null,
+ "allow_trash": null,
+ "autoname": "field:party_type_name",
+ "change_log": null,
+ "client_script": null,
+ "client_script_core": null,
+ "client_string": null,
+ "colour": null,
+ "creation": "2014-04-07 12:32:18.010384",
+ "custom": null,
+ "default_print_format": null,
+ "description": null,
+ "docstatus": 0,
+ "doctype": "DocType",
+ "document_type": "Master",
+ "dt_template": null,
+ "fields": [
+ {
+ "allow_on_submit": null,
+ "default": null,
+ "depends_on": null,
+ "description": null,
+ "fieldname": "party_type_name",
+ "fieldtype": "Data",
+ "hidden": null,
+ "ignore_restrictions": null,
+ "in_filter": null,
+ "in_list_view": 1,
+ "label": "Party Type Name",
+ "no_column": null,
+ "no_copy": null,
+ "oldfieldname": null,
+ "oldfieldtype": null,
+ "options": null,
+ "permlevel": 0,
+ "print_hide": null,
+ "print_width": null,
+ "read_only": null,
+ "report_hide": null,
+ "reqd": 1,
+ "search_index": null,
+ "set_only_once": null,
+ "trigger": null,
+ "width": null
+ },
+ {
+ "allow_on_submit": null,
+ "default": null,
+ "depends_on": null,
+ "description": null,
+ "fieldname": "parent_party_type",
+ "fieldtype": "Link",
+ "hidden": null,
+ "ignore_restrictions": null,
+ "in_filter": null,
+ "in_list_view": null,
+ "label": "Parent Party Type",
+ "no_column": null,
+ "no_copy": null,
+ "oldfieldname": null,
+ "oldfieldtype": null,
+ "options": "Party Type",
+ "permlevel": 0,
+ "print_hide": null,
+ "print_width": null,
+ "read_only": null,
+ "report_hide": null,
+ "reqd": null,
+ "search_index": null,
+ "set_only_once": null,
+ "trigger": null,
+ "width": null
+ },
+ {
+ "allow_on_submit": null,
+ "default": "Yes",
+ "depends_on": null,
+ "description": null,
+ "fieldname": "allow_children",
+ "fieldtype": "Select",
+ "hidden": null,
+ "ignore_restrictions": null,
+ "in_filter": null,
+ "in_list_view": null,
+ "label": "Allow Children",
+ "no_column": null,
+ "no_copy": null,
+ "oldfieldname": null,
+ "oldfieldtype": null,
+ "options": "Yes\nNo",
+ "permlevel": 0,
+ "print_hide": null,
+ "print_width": null,
+ "read_only": null,
+ "report_hide": null,
+ "reqd": null,
+ "search_index": null,
+ "set_only_once": null,
+ "trigger": null,
+ "width": null
+ },
+ {
+ "allow_on_submit": null,
+ "default": null,
+ "depends_on": null,
+ "description": null,
+ "fieldname": "default_price_list",
+ "fieldtype": "Link",
+ "hidden": null,
+ "ignore_restrictions": null,
+ "in_filter": null,
+ "in_list_view": null,
+ "label": "Default Price List",
+ "no_column": null,
+ "no_copy": null,
+ "oldfieldname": null,
+ "oldfieldtype": null,
+ "options": "Price List",
+ "permlevel": 0,
+ "print_hide": null,
+ "print_width": null,
+ "read_only": null,
+ "report_hide": null,
+ "reqd": null,
+ "search_index": null,
+ "set_only_once": null,
+ "trigger": null,
+ "width": null
+ },
+ {
+ "allow_on_submit": null,
+ "default": null,
+ "depends_on": null,
+ "description": null,
+ "fieldname": "lft",
+ "fieldtype": "Int",
+ "hidden": 1,
+ "ignore_restrictions": null,
+ "in_filter": null,
+ "in_list_view": null,
+ "label": "LFT",
+ "no_column": null,
+ "no_copy": null,
+ "oldfieldname": null,
+ "oldfieldtype": null,
+ "options": null,
+ "permlevel": 0,
+ "print_hide": null,
+ "print_width": null,
+ "read_only": 1,
+ "report_hide": null,
+ "reqd": null,
+ "search_index": 1,
+ "set_only_once": null,
+ "trigger": null,
+ "width": null
+ },
+ {
+ "allow_on_submit": null,
+ "default": null,
+ "depends_on": null,
+ "description": null,
+ "fieldname": "rgt",
+ "fieldtype": "Int",
+ "hidden": 1,
+ "ignore_restrictions": null,
+ "in_filter": null,
+ "in_list_view": null,
+ "label": "RGT",
+ "no_column": null,
+ "no_copy": null,
+ "oldfieldname": null,
+ "oldfieldtype": null,
+ "options": null,
+ "permlevel": 0,
+ "print_hide": null,
+ "print_width": null,
+ "read_only": 1,
+ "report_hide": null,
+ "reqd": null,
+ "search_index": 1,
+ "set_only_once": null,
+ "trigger": null,
+ "width": null
+ },
+ {
+ "allow_on_submit": null,
+ "default": null,
+ "depends_on": null,
+ "description": null,
+ "fieldname": "old_parent",
+ "fieldtype": "Data",
+ "hidden": 1,
+ "ignore_restrictions": null,
+ "in_filter": null,
+ "in_list_view": null,
+ "label": "Old Parent",
+ "no_column": null,
+ "no_copy": null,
+ "oldfieldname": null,
+ "oldfieldtype": null,
+ "options": null,
+ "permlevel": 0,
+ "print_hide": null,
+ "print_width": null,
+ "read_only": 1,
+ "report_hide": null,
+ "reqd": null,
+ "search_index": null,
+ "set_only_once": null,
+ "trigger": null,
+ "width": null
+ }
+ ],
+ "hide_heading": null,
+ "hide_toolbar": null,
+ "icon": null,
+ "idx": null,
+ "in_create": null,
+ "in_dialog": null,
+ "is_submittable": null,
+ "is_transaction_doc": null,
+ "issingle": null,
+ "istable": null,
+ "max_attachments": null,
+ "menu_index": null,
+ "modified": "2014-04-07 12:54:46.254776",
+ "modified_by": "Administrator",
+ "module": "Contacts",
+ "name": "Party Type",
+ "name_case": null,
+ "owner": "Administrator",
+ "parent": null,
+ "parent_node": null,
+ "parentfield": null,
+ "parenttype": null,
+ "permissions": [
+ {
+ "amend": null,
+ "cancel": null,
+ "create": 1,
+ "delete": null,
+ "email": null,
+ "export": null,
+ "import": null,
+ "match": null,
+ "permlevel": 0,
+ "print": null,
+ "read": 1,
+ "report": null,
+ "restrict": null,
+ "restricted": null,
+ "role": "Sales User",
+ "submit": null,
+ "write": 1
+ },
+ {
+ "amend": null,
+ "cancel": null,
+ "create": 1,
+ "delete": null,
+ "email": null,
+ "export": null,
+ "import": null,
+ "match": null,
+ "permlevel": 0,
+ "print": null,
+ "read": 1,
+ "report": null,
+ "restrict": null,
+ "restricted": null,
+ "role": "Purchase User",
+ "submit": null,
+ "write": 1
+ }
+ ],
+ "plugin": null,
+ "print_outline": null,
+ "read_only": null,
+ "read_only_onload": null,
+ "search_fields": null,
+ "section_style": null,
+ "server_code": null,
+ "server_code_compiled": null,
+ "server_code_core": null,
+ "server_code_error": null,
+ "show_in_menu": null,
+ "smallicon": null,
+ "subject": null,
+ "tag_fields": null,
+ "title_field": null,
+ "use_template": null,
+ "version": null
+}
\ No newline at end of file
diff --git a/erpnext/contacts/doctype/party_type/party_type.py b/erpnext/contacts/doctype/party_type/party_type.py
new file mode 100644
index 0000000..3f752ed
--- /dev/null
+++ b/erpnext/contacts/doctype/party_type/party_type.py
@@ -0,0 +1,9 @@
+# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import frappe
+from frappe.utils.nestedset import NestedSet
+
+class PartyType(NestedSet):
+ nsm_parent_field = 'parent_party_type';
diff --git a/erpnext/modules.txt b/erpnext/modules.txt
index f7857e4..92614d8 100644
--- a/erpnext/modules.txt
+++ b/erpnext/modules.txt
@@ -8,4 +8,5 @@
setup
stock
support
-utilities
\ No newline at end of file
+utilities
+contacts
diff --git a/erpnext/setup/doctype/customer_group/customer_group.py b/erpnext/setup/doctype/customer_group/customer_group.py
index 4443567..11a15fa 100644
--- a/erpnext/setup/doctype/customer_group/customer_group.py
+++ b/erpnext/setup/doctype/customer_group/customer_group.py
@@ -6,8 +6,8 @@
from frappe import msgprint
-from frappe.utils.nestedset import DocTypeNestedSet
-class CustomerGroup(DocTypeNestedSet):
+from frappe.utils.nestedset import NestedSet
+class CustomerGroup(NestedSet):
nsm_parent_field = 'parent_customer_group';
def validate(self):
diff --git a/erpnext/setup/doctype/item_group/item_group.py b/erpnext/setup/doctype/item_group/item_group.py
index e1f79a5..e744ae2 100644
--- a/erpnext/setup/doctype/item_group/item_group.py
+++ b/erpnext/setup/doctype/item_group/item_group.py
@@ -4,9 +4,9 @@
from __future__ import unicode_literals
import frappe
-from frappe.utils.nestedset import DocTypeNestedSet
+from frappe.utils.nestedset import NestedSet
-class ItemGroup(DocTypeNestedSet):
+class ItemGroup(NestedSet):
nsm_parent_field = 'parent_item_group'
def validate(self):
@@ -15,7 +15,7 @@
self.parent_item_group)
def on_update(self):
- DocTypeNestedSet.on_update(self)
+ NestedSet.on_update(self)
self.validate_name_with_item()
diff --git a/erpnext/setup/doctype/sales_person/sales_person.py b/erpnext/setup/doctype/sales_person/sales_person.py
index 7f87210..6389722 100644
--- a/erpnext/setup/doctype/sales_person/sales_person.py
+++ b/erpnext/setup/doctype/sales_person/sales_person.py
@@ -5,9 +5,9 @@
import frappe
from frappe.utils import flt
-from frappe.utils.nestedset import DocTypeNestedSet
+from frappe.utils.nestedset import NestedSet
-class SalesPerson(DocTypeNestedSet):
+class SalesPerson(NestedSet):
nsm_parent_field = 'parent_sales_person';
def validate(self):
diff --git a/erpnext/setup/doctype/territory/territory.py b/erpnext/setup/doctype/territory/territory.py
index a015644..83eae91 100644
--- a/erpnext/setup/doctype/territory/territory.py
+++ b/erpnext/setup/doctype/territory/territory.py
@@ -7,9 +7,9 @@
from frappe.utils import flt
-from frappe.utils.nestedset import DocTypeNestedSet
+from frappe.utils.nestedset import NestedSet
-class Territory(DocTypeNestedSet):
+class Territory(NestedSet):
nsm_parent_field = 'parent_territory'
def validate(self):
diff --git a/erpnext/setup/page/setup_wizard/setup_wizard.py b/erpnext/setup/page/setup_wizard/setup_wizard.py
index 3f52463..2bd906f 100644
--- a/erpnext/setup/page/setup_wizard/setup_wizard.py
+++ b/erpnext/setup/page/setup_wizard/setup_wizard.py
@@ -12,13 +12,13 @@
def setup_account(args=None):
# if frappe.db.sql("select name from tabCompany"):
# frappe.throw(_("Setup Already Complete!!"))
-
+
if not args:
args = frappe.local.form_dict
if isinstance(args, basestring):
args = json.loads(args)
args = frappe._dict(args)
-
+
update_user_name(args)
create_fiscal_year_and_company(args)
set_defaults(args)
@@ -35,12 +35,12 @@
frappe.clear_cache()
frappe.db.commit()
-
+
# suppress msgprints
frappe.local.message_log = []
return "okay"
-
+
def update_user_name(args):
if args.get("email"):
args['name'] = args.get("email")
@@ -59,18 +59,18 @@
args['name'] = frappe.session.user
# Update User
- if not args.get('last_name') or args.get('last_name')=='None':
+ if not args.get('last_name') or args.get('last_name')=='None':
args['last_name'] = None
frappe.db.sql("""update `tabUser` SET first_name=%(first_name)s,
last_name=%(last_name)s WHERE name=%(name)s""", args)
-
+
if args.get("attach_user"):
filename, filetype, content = args.get("attach_user").split(",")
fileurl = save_file(filename, content, "User", args.get("name"), decode=True).file_name
frappe.db.set_value("User", args.get("name"), "user_image", fileurl)
-
+
add_all_roles_to(args.get("name"))
-
+
def create_fiscal_year_and_company(args):
curr_fiscal_year = get_fy_details(args.get('fy_start_date'), args.get('fy_end_date'))
frappe.get_doc({
@@ -91,9 +91,9 @@
'country': args.get('country'),
'chart_of_accounts': args.get(('chart_of_accounts')),
}).insert()
-
+
args["curr_fiscal_year"] = curr_fiscal_year
-
+
def create_price_lists(args):
for pl_type in ["Selling", "Buying"]:
frappe.get_doc({
@@ -107,11 +107,11 @@
"territory": "All Territories"
}
}).insert()
-
+
def set_defaults(args):
# enable default currency
frappe.db.set_value("Currency", args.get("currency"), "enabled", 1)
-
+
global_defaults = frappe.get_doc("Global Defaults", "Global Defaults")
global_defaults.update({
'current_fiscal_year': args.curr_fiscal_year,
@@ -123,7 +123,7 @@
"time_zone": args.get("time_zone")
})
global_defaults.save()
-
+
accounts_settings = frappe.get_doc("Accounts Settings")
accounts_settings.auto_accounting_for_stock = 1
accounts_settings.save()
@@ -134,7 +134,7 @@
stock_settings.stock_uom = "Nos"
stock_settings.auto_indent = 1
stock_settings.save()
-
+
selling_settings = frappe.get_doc("Selling Settings")
selling_settings.cust_master_name = "Customer Name"
selling_settings.so_required = "No"
@@ -164,7 +164,7 @@
# default
frappe.db.set_default("company_name", args["company_name"])
-
+
def create_feed_and_todo():
"""update activty feed and create todo for creation of item, customer, vendor"""
from erpnext.home import make_feed
@@ -174,9 +174,9 @@
def create_email_digest():
from frappe.utils.user import get_system_managers
system_managers = get_system_managers(only_name=True)
- if not system_managers:
+ if not system_managers:
return
-
+
companies = frappe.db.sql_list("select name FROM `tabCompany`")
for company in companies:
if not frappe.db.exists("Email Digest", "Default Weekly Digest - " + company):
@@ -188,12 +188,12 @@
"recipient_list": "\n".join(system_managers)
})
- for fieldname in edigest.meta.get_fieldnames({"fieldtype": "Check"}):
+ for fieldname in edigest.meta.get("fields", {"fieldtype": "Check"}):
if fieldname != "scheduler_errors":
edigest.set(fieldname, 1)
-
+
edigest.insert()
-
+
# scheduler errors digest
if companies:
edigest = frappe.new_doc("Email Digest")
@@ -206,7 +206,7 @@
"enabled": 1
})
edigest.insert()
-
+
def get_fy_details(fy_start_date, fy_end_date):
start_year = getdate(fy_start_date).year
if start_year == getdate(fy_end_date).year:
@@ -245,12 +245,12 @@
"stock_uom": args.get("item_uom_" + str(i)),
"default_warehouse": item_group!="Service" and ("Finished Goods - " + args.get("company_abbr")) or ""
}).insert()
-
+
if args.get("item_img_" + str(i)):
filename, filetype, content = args.get("item_img_" + str(i)).split(",")
fileurl = save_file(filename, content, "Item", item, decode=True).file_name
frappe.db.set_value("Item", item, "image", fileurl)
-
+
for i in xrange(1,6):
item = args.get("item_buy_" + str(i))
if item:
@@ -266,7 +266,7 @@
"stock_uom": args.get("item_buy_uom_" + str(i)),
"default_warehouse": item_group!="Service" and ("Stores - " + args.get("company_abbr")) or ""
}).insert()
-
+
if args.get("item_img_" + str(i)):
filename, filetype, content = args.get("item_img_" + str(i)).split(",")
fileurl = save_file(filename, content, "Item", item, decode=True).file_name
@@ -285,7 +285,7 @@
"territory": args.get("country"),
"company": args.get("company_name")
}).insert()
-
+
if args.get("customer_contact_" + str(i)):
contact = args.get("customer_contact_" + str(i)).split(" ")
frappe.get_doc({
@@ -294,7 +294,7 @@
"first_name":contact[0],
"last_name": len(contact) > 1 and contact[1] or ""
}).insert()
-
+
def create_suppliers(args):
for i in xrange(1,6):
supplier = args.get("supplier_" + str(i))
@@ -323,11 +323,11 @@
"letter_head_name": "Standard",
"is_default": 1
}).insert()
-
+
filename, filetype, content = args.get("attach_letterhead").split(",")
fileurl = save_file(filename, content, "Letter Head", "Standard", decode=True).file_name
frappe.db.set_value("Letter Head", "Standard", "content", "<img src='%s' style='max-width: 100%%;'>" % fileurl)
-
+
def add_all_roles_to(name):
user = frappe.get_doc("User", name)
for role in frappe.db.sql("""select name from tabRole"""):
@@ -348,4 +348,4 @@
"territory_name": name.replace("'", ""),
"parent_territory": root_territory,
"is_group": "No"
- }).insert()
\ No newline at end of file
+ }).insert()