mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-19 13:09:17 +00:00
Merge branch 'model-cleanup' of github.com:frappe/erpnext into model-cleanup
This commit is contained in:
@@ -6,9 +6,9 @@ import frappe
|
|||||||
|
|
||||||
from frappe import msgprint, _
|
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'
|
nsm_parent_field = 'parent_cost_center'
|
||||||
|
|
||||||
def autoname(self):
|
def autoname(self):
|
||||||
|
|||||||
@@ -8,22 +8,22 @@ erpnext.accounts.JournalVoucher = frappe.ui.form.Controller.extend({
|
|||||||
this.load_defaults();
|
this.load_defaults();
|
||||||
this.setup_queries();
|
this.setup_queries();
|
||||||
},
|
},
|
||||||
|
|
||||||
load_defaults: function() {
|
load_defaults: function() {
|
||||||
if(this.frm.doc.__islocal && this.frm.doc.company) {
|
if(this.frm.doc.__islocal && this.frm.doc.company) {
|
||||||
frappe.model.set_default_values(this.frm.doc);
|
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);
|
frappe.model.set_default_values(jvd);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
if(!this.frm.doc.amended_from) this.frm.doc.posting_date = get_today();
|
if(!this.frm.doc.amended_from) this.frm.doc.posting_date = get_today();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
setup_queries: function() {
|
setup_queries: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
|
|
||||||
$.each(["account", "cost_center"], function(i, fieldname) {
|
$.each(["account", "cost_center"], function(i, fieldname) {
|
||||||
me.frm.set_query(fieldname, "entries", function() {
|
me.frm.set_query(fieldname, "entries", function() {
|
||||||
frappe.model.validate_missing(me.frm.doc, "company");
|
frappe.model.validate_missing(me.frm.doc, "company");
|
||||||
@@ -35,8 +35,8 @@ erpnext.accounts.JournalVoucher = frappe.ui.form.Controller.extend({
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$.each([["against_voucher", "Purchase Invoice", "credit_to"],
|
$.each([["against_voucher", "Purchase Invoice", "credit_to"],
|
||||||
["against_invoice", "Sales Invoice", "debit_to"]], function(i, opts) {
|
["against_invoice", "Sales Invoice", "debit_to"]], function(i, opts) {
|
||||||
me.frm.set_query(opts[0], "entries", function(doc, cdt, cdn) {
|
me.frm.set_query(opts[0], "entries", function(doc, cdt, cdn) {
|
||||||
var jvd = frappe.get_doc(cdt, cdn);
|
var jvd = frappe.get_doc(cdt, cdn);
|
||||||
@@ -50,49 +50,49 @@ erpnext.accounts.JournalVoucher = frappe.ui.form.Controller.extend({
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
this.frm.set_query("against_jv", "entries", function(doc, cdt, cdn) {
|
this.frm.set_query("against_jv", "entries", function(doc, cdt, cdn) {
|
||||||
var jvd = frappe.get_doc(cdt, cdn);
|
var jvd = frappe.get_doc(cdt, cdn);
|
||||||
frappe.model.validate_missing(jvd, "account");
|
frappe.model.validate_missing(jvd, "account");
|
||||||
|
|
||||||
return {
|
return {
|
||||||
query: "accounts.doctype.journal_voucher.journal_voucher.get_against_jv",
|
query: "accounts.doctype.journal_voucher.journal_voucher.get_against_jv",
|
||||||
filters: { account: jvd.account }
|
filters: { account: jvd.account }
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
against_voucher: function(doc, cdt, cdn) {
|
against_voucher: function(doc, cdt, cdn) {
|
||||||
var d = frappe.get_doc(cdt, cdn);
|
var d = frappe.get_doc(cdt, cdn);
|
||||||
if (d.against_voucher && !flt(d.debit)) {
|
if (d.against_voucher && !flt(d.debit)) {
|
||||||
this.get_outstanding({
|
this.get_outstanding({
|
||||||
'doctype': 'Purchase Invoice',
|
'doctype': 'Purchase Invoice',
|
||||||
'docname': d.against_voucher
|
'docname': d.against_voucher
|
||||||
}, d)
|
}, d)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
against_invoice: function(doc, cdt, cdn) {
|
against_invoice: function(doc, cdt, cdn) {
|
||||||
var d = frappe.get_doc(cdt, cdn);
|
var d = frappe.get_doc(cdt, cdn);
|
||||||
if (d.against_invoice && !flt(d.credit)) {
|
if (d.against_invoice && !flt(d.credit)) {
|
||||||
this.get_outstanding({
|
this.get_outstanding({
|
||||||
'doctype': 'Sales Invoice',
|
'doctype': 'Sales Invoice',
|
||||||
'docname': d.against_invoice
|
'docname': d.against_invoice
|
||||||
}, d)
|
}, d)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
against_jv: function(doc, cdt, cdn) {
|
against_jv: function(doc, cdt, cdn) {
|
||||||
var d = frappe.get_doc(cdt, cdn);
|
var d = frappe.get_doc(cdt, cdn);
|
||||||
if (d.against_jv && !flt(d.credit) && !flt(d.debit)) {
|
if (d.against_jv && !flt(d.credit) && !flt(d.debit)) {
|
||||||
this.get_outstanding({
|
this.get_outstanding({
|
||||||
'doctype': 'Journal Voucher',
|
'doctype': 'Journal Voucher',
|
||||||
'docname': d.against_jv,
|
'docname': d.against_jv,
|
||||||
'account': d.account
|
'account': d.account
|
||||||
}, d)
|
}, d)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
get_outstanding: function(args, child) {
|
get_outstanding: function(args, child) {
|
||||||
var me = this;
|
var me = this;
|
||||||
return this.frm.call({
|
return this.frm.call({
|
||||||
@@ -104,7 +104,7 @@ erpnext.accounts.JournalVoucher = frappe.ui.form.Controller.extend({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
cur_frm.script_manager.make(erpnext.accounts.JournalVoucher);
|
cur_frm.script_manager.make(erpnext.accounts.JournalVoucher);
|
||||||
@@ -113,7 +113,7 @@ cur_frm.cscript.refresh = function(doc) {
|
|||||||
cur_frm.cscript.is_opening(doc)
|
cur_frm.cscript.is_opening(doc)
|
||||||
erpnext.hide_naming_series();
|
erpnext.hide_naming_series();
|
||||||
cur_frm.cscript.voucher_type(doc);
|
cur_frm.cscript.voucher_type(doc);
|
||||||
if(doc.docstatus==1) {
|
if(doc.docstatus==1) {
|
||||||
cur_frm.appframe.add_button(frappe._('View Ledger'), function() {
|
cur_frm.appframe.add_button(frappe._('View Ledger'), function() {
|
||||||
frappe.route_options = {
|
frappe.route_options = {
|
||||||
"voucher_no": doc.name,
|
"voucher_no": doc.name,
|
||||||
@@ -154,7 +154,7 @@ cur_frm.cscript.debit = function(doc,dt,dn) { cur_frm.cscript.update_totals(doc)
|
|||||||
cur_frm.cscript.credit = function(doc,dt,dn) { cur_frm.cscript.update_totals(doc); }
|
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.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){
|
return $c_obj(cur_frm.doc, 'get_balance', '', function(r, rt){
|
||||||
cur_frm.refresh();
|
cur_frm.refresh();
|
||||||
});
|
});
|
||||||
@@ -174,7 +174,7 @@ cur_frm.cscript.account = function(doc,dt,dn) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.cscript.validate = function(doc,cdt,cdn) {
|
cur_frm.cscript.validate = function(doc,cdt,cdn) {
|
||||||
cur_frm.cscript.update_totals(doc);
|
cur_frm.cscript.update_totals(doc);
|
||||||
@@ -195,7 +195,7 @@ cur_frm.cscript.voucher_type = function(doc, cdt, cdn) {
|
|||||||
|
|
||||||
if((doc.entries || []).length!==0 || !doc.company) // too early
|
if((doc.entries || []).length!==0 || !doc.company) // too early
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var update_jv_details = function(doc, r) {
|
var update_jv_details = function(doc, r) {
|
||||||
$.each(r.message, function(i, d) {
|
$.each(r.message, function(i, d) {
|
||||||
var jvdetail = frappe.model.add_child(doc, "Journal Voucher Detail", "entries");
|
var jvdetail = frappe.model.add_child(doc, "Journal Voucher Detail", "entries");
|
||||||
@@ -204,7 +204,7 @@ cur_frm.cscript.voucher_type = function(doc, cdt, cdn) {
|
|||||||
});
|
});
|
||||||
refresh_field("entries");
|
refresh_field("entries");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(in_list(["Bank Voucher", "Cash Voucher"], doc.voucher_type)) {
|
if(in_list(["Bank Voucher", "Cash Voucher"], doc.voucher_type)) {
|
||||||
return frappe.call({
|
return frappe.call({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
@@ -227,7 +227,7 @@ cur_frm.cscript.voucher_type = function(doc, cdt, cdn) {
|
|||||||
"company": doc.company
|
"company": doc.company
|
||||||
},
|
},
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
frappe.model.clear_table("Journal Voucher Detail", "Journal Voucher",
|
frappe.model.clear_table("Journal Voucher Detail", "Journal Voucher",
|
||||||
doc.name, "entries");
|
doc.name, "entries");
|
||||||
if(r.message) {
|
if(r.message) {
|
||||||
update_jv_details(doc, r);
|
update_jv_details(doc, r);
|
||||||
@@ -236,4 +236,4 @@ cur_frm.cscript.voucher_type = function(doc, cdt, cdn) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
0
erpnext/contacts/__init__.py
Normal file
0
erpnext/contacts/__init__.py
Normal file
0
erpnext/contacts/doctype/__init__.py
Normal file
0
erpnext/contacts/doctype/__init__.py
Normal file
0
erpnext/contacts/doctype/party_type/__init__.py
Normal file
0
erpnext/contacts/doctype/party_type/__init__.py
Normal file
302
erpnext/contacts/doctype/party_type/party_type.json
Normal file
302
erpnext/contacts/doctype/party_type/party_type.json
Normal file
@@ -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
|
||||||
|
}
|
||||||
9
erpnext/contacts/doctype/party_type/party_type.py
Normal file
9
erpnext/contacts/doctype/party_type/party_type.py
Normal file
@@ -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';
|
||||||
@@ -8,4 +8,5 @@ selling
|
|||||||
setup
|
setup
|
||||||
stock
|
stock
|
||||||
support
|
support
|
||||||
utilities
|
utilities
|
||||||
|
contacts
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import frappe
|
|||||||
from frappe import msgprint
|
from frappe import msgprint
|
||||||
|
|
||||||
|
|
||||||
from frappe.utils.nestedset import DocTypeNestedSet
|
from frappe.utils.nestedset import NestedSet
|
||||||
class CustomerGroup(DocTypeNestedSet):
|
class CustomerGroup(NestedSet):
|
||||||
nsm_parent_field = 'parent_customer_group';
|
nsm_parent_field = 'parent_customer_group';
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
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'
|
nsm_parent_field = 'parent_item_group'
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
@@ -15,7 +15,7 @@ class ItemGroup(DocTypeNestedSet):
|
|||||||
self.parent_item_group)
|
self.parent_item_group)
|
||||||
|
|
||||||
def on_update(self):
|
def on_update(self):
|
||||||
DocTypeNestedSet.on_update(self)
|
NestedSet.on_update(self)
|
||||||
|
|
||||||
self.validate_name_with_item()
|
self.validate_name_with_item()
|
||||||
|
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
from frappe.utils import flt
|
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';
|
nsm_parent_field = 'parent_sales_person';
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ import frappe
|
|||||||
|
|
||||||
from frappe.utils import flt
|
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'
|
nsm_parent_field = 'parent_territory'
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
|
|||||||
@@ -12,13 +12,13 @@ from frappe.utils.file_manager import save_file
|
|||||||
def setup_account(args=None):
|
def setup_account(args=None):
|
||||||
# if frappe.db.sql("select name from tabCompany"):
|
# if frappe.db.sql("select name from tabCompany"):
|
||||||
# frappe.throw(_("Setup Already Complete!!"))
|
# frappe.throw(_("Setup Already Complete!!"))
|
||||||
|
|
||||||
if not args:
|
if not args:
|
||||||
args = frappe.local.form_dict
|
args = frappe.local.form_dict
|
||||||
if isinstance(args, basestring):
|
if isinstance(args, basestring):
|
||||||
args = json.loads(args)
|
args = json.loads(args)
|
||||||
args = frappe._dict(args)
|
args = frappe._dict(args)
|
||||||
|
|
||||||
update_user_name(args)
|
update_user_name(args)
|
||||||
create_fiscal_year_and_company(args)
|
create_fiscal_year_and_company(args)
|
||||||
set_defaults(args)
|
set_defaults(args)
|
||||||
@@ -35,12 +35,12 @@ def setup_account(args=None):
|
|||||||
|
|
||||||
frappe.clear_cache()
|
frappe.clear_cache()
|
||||||
frappe.db.commit()
|
frappe.db.commit()
|
||||||
|
|
||||||
# suppress msgprints
|
# suppress msgprints
|
||||||
frappe.local.message_log = []
|
frappe.local.message_log = []
|
||||||
|
|
||||||
return "okay"
|
return "okay"
|
||||||
|
|
||||||
def update_user_name(args):
|
def update_user_name(args):
|
||||||
if args.get("email"):
|
if args.get("email"):
|
||||||
args['name'] = args.get("email")
|
args['name'] = args.get("email")
|
||||||
@@ -59,18 +59,18 @@ def update_user_name(args):
|
|||||||
args['name'] = frappe.session.user
|
args['name'] = frappe.session.user
|
||||||
|
|
||||||
# Update 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
|
args['last_name'] = None
|
||||||
frappe.db.sql("""update `tabUser` SET first_name=%(first_name)s,
|
frappe.db.sql("""update `tabUser` SET first_name=%(first_name)s,
|
||||||
last_name=%(last_name)s WHERE name=%(name)s""", args)
|
last_name=%(last_name)s WHERE name=%(name)s""", args)
|
||||||
|
|
||||||
if args.get("attach_user"):
|
if args.get("attach_user"):
|
||||||
filename, filetype, content = args.get("attach_user").split(",")
|
filename, filetype, content = args.get("attach_user").split(",")
|
||||||
fileurl = save_file(filename, content, "User", args.get("name"), decode=True).file_name
|
fileurl = save_file(filename, content, "User", args.get("name"), decode=True).file_name
|
||||||
frappe.db.set_value("User", args.get("name"), "user_image", fileurl)
|
frappe.db.set_value("User", args.get("name"), "user_image", fileurl)
|
||||||
|
|
||||||
add_all_roles_to(args.get("name"))
|
add_all_roles_to(args.get("name"))
|
||||||
|
|
||||||
def create_fiscal_year_and_company(args):
|
def create_fiscal_year_and_company(args):
|
||||||
curr_fiscal_year = get_fy_details(args.get('fy_start_date'), args.get('fy_end_date'))
|
curr_fiscal_year = get_fy_details(args.get('fy_start_date'), args.get('fy_end_date'))
|
||||||
frappe.get_doc({
|
frappe.get_doc({
|
||||||
@@ -91,9 +91,9 @@ def create_fiscal_year_and_company(args):
|
|||||||
'country': args.get('country'),
|
'country': args.get('country'),
|
||||||
'chart_of_accounts': args.get(('chart_of_accounts')),
|
'chart_of_accounts': args.get(('chart_of_accounts')),
|
||||||
}).insert()
|
}).insert()
|
||||||
|
|
||||||
args["curr_fiscal_year"] = curr_fiscal_year
|
args["curr_fiscal_year"] = curr_fiscal_year
|
||||||
|
|
||||||
def create_price_lists(args):
|
def create_price_lists(args):
|
||||||
for pl_type in ["Selling", "Buying"]:
|
for pl_type in ["Selling", "Buying"]:
|
||||||
frappe.get_doc({
|
frappe.get_doc({
|
||||||
@@ -107,11 +107,11 @@ def create_price_lists(args):
|
|||||||
"territory": "All Territories"
|
"territory": "All Territories"
|
||||||
}
|
}
|
||||||
}).insert()
|
}).insert()
|
||||||
|
|
||||||
def set_defaults(args):
|
def set_defaults(args):
|
||||||
# enable default currency
|
# enable default currency
|
||||||
frappe.db.set_value("Currency", args.get("currency"), "enabled", 1)
|
frappe.db.set_value("Currency", args.get("currency"), "enabled", 1)
|
||||||
|
|
||||||
global_defaults = frappe.get_doc("Global Defaults", "Global Defaults")
|
global_defaults = frappe.get_doc("Global Defaults", "Global Defaults")
|
||||||
global_defaults.update({
|
global_defaults.update({
|
||||||
'current_fiscal_year': args.curr_fiscal_year,
|
'current_fiscal_year': args.curr_fiscal_year,
|
||||||
@@ -123,7 +123,7 @@ def set_defaults(args):
|
|||||||
"time_zone": args.get("time_zone")
|
"time_zone": args.get("time_zone")
|
||||||
})
|
})
|
||||||
global_defaults.save()
|
global_defaults.save()
|
||||||
|
|
||||||
accounts_settings = frappe.get_doc("Accounts Settings")
|
accounts_settings = frappe.get_doc("Accounts Settings")
|
||||||
accounts_settings.auto_accounting_for_stock = 1
|
accounts_settings.auto_accounting_for_stock = 1
|
||||||
accounts_settings.save()
|
accounts_settings.save()
|
||||||
@@ -134,7 +134,7 @@ def set_defaults(args):
|
|||||||
stock_settings.stock_uom = "Nos"
|
stock_settings.stock_uom = "Nos"
|
||||||
stock_settings.auto_indent = 1
|
stock_settings.auto_indent = 1
|
||||||
stock_settings.save()
|
stock_settings.save()
|
||||||
|
|
||||||
selling_settings = frappe.get_doc("Selling Settings")
|
selling_settings = frappe.get_doc("Selling Settings")
|
||||||
selling_settings.cust_master_name = "Customer Name"
|
selling_settings.cust_master_name = "Customer Name"
|
||||||
selling_settings.so_required = "No"
|
selling_settings.so_required = "No"
|
||||||
@@ -164,7 +164,7 @@ def set_defaults(args):
|
|||||||
|
|
||||||
# default
|
# default
|
||||||
frappe.db.set_default("company_name", args["company_name"])
|
frappe.db.set_default("company_name", args["company_name"])
|
||||||
|
|
||||||
def create_feed_and_todo():
|
def create_feed_and_todo():
|
||||||
"""update activty feed and create todo for creation of item, customer, vendor"""
|
"""update activty feed and create todo for creation of item, customer, vendor"""
|
||||||
from erpnext.home import make_feed
|
from erpnext.home import make_feed
|
||||||
@@ -174,9 +174,9 @@ def create_feed_and_todo():
|
|||||||
def create_email_digest():
|
def create_email_digest():
|
||||||
from frappe.utils.user import get_system_managers
|
from frappe.utils.user import get_system_managers
|
||||||
system_managers = get_system_managers(only_name=True)
|
system_managers = get_system_managers(only_name=True)
|
||||||
if not system_managers:
|
if not system_managers:
|
||||||
return
|
return
|
||||||
|
|
||||||
companies = frappe.db.sql_list("select name FROM `tabCompany`")
|
companies = frappe.db.sql_list("select name FROM `tabCompany`")
|
||||||
for company in companies:
|
for company in companies:
|
||||||
if not frappe.db.exists("Email Digest", "Default Weekly Digest - " + company):
|
if not frappe.db.exists("Email Digest", "Default Weekly Digest - " + company):
|
||||||
@@ -188,12 +188,12 @@ def create_email_digest():
|
|||||||
"recipient_list": "\n".join(system_managers)
|
"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":
|
if fieldname != "scheduler_errors":
|
||||||
edigest.set(fieldname, 1)
|
edigest.set(fieldname, 1)
|
||||||
|
|
||||||
edigest.insert()
|
edigest.insert()
|
||||||
|
|
||||||
# scheduler errors digest
|
# scheduler errors digest
|
||||||
if companies:
|
if companies:
|
||||||
edigest = frappe.new_doc("Email Digest")
|
edigest = frappe.new_doc("Email Digest")
|
||||||
@@ -206,7 +206,7 @@ def create_email_digest():
|
|||||||
"enabled": 1
|
"enabled": 1
|
||||||
})
|
})
|
||||||
edigest.insert()
|
edigest.insert()
|
||||||
|
|
||||||
def get_fy_details(fy_start_date, fy_end_date):
|
def get_fy_details(fy_start_date, fy_end_date):
|
||||||
start_year = getdate(fy_start_date).year
|
start_year = getdate(fy_start_date).year
|
||||||
if start_year == getdate(fy_end_date).year:
|
if start_year == getdate(fy_end_date).year:
|
||||||
@@ -245,12 +245,12 @@ def create_items(args):
|
|||||||
"stock_uom": args.get("item_uom_" + str(i)),
|
"stock_uom": args.get("item_uom_" + str(i)),
|
||||||
"default_warehouse": item_group!="Service" and ("Finished Goods - " + args.get("company_abbr")) or ""
|
"default_warehouse": item_group!="Service" and ("Finished Goods - " + args.get("company_abbr")) or ""
|
||||||
}).insert()
|
}).insert()
|
||||||
|
|
||||||
if args.get("item_img_" + str(i)):
|
if args.get("item_img_" + str(i)):
|
||||||
filename, filetype, content = args.get("item_img_" + str(i)).split(",")
|
filename, filetype, content = args.get("item_img_" + str(i)).split(",")
|
||||||
fileurl = save_file(filename, content, "Item", item, decode=True).file_name
|
fileurl = save_file(filename, content, "Item", item, decode=True).file_name
|
||||||
frappe.db.set_value("Item", item, "image", fileurl)
|
frappe.db.set_value("Item", item, "image", fileurl)
|
||||||
|
|
||||||
for i in xrange(1,6):
|
for i in xrange(1,6):
|
||||||
item = args.get("item_buy_" + str(i))
|
item = args.get("item_buy_" + str(i))
|
||||||
if item:
|
if item:
|
||||||
@@ -266,7 +266,7 @@ def create_items(args):
|
|||||||
"stock_uom": args.get("item_buy_uom_" + str(i)),
|
"stock_uom": args.get("item_buy_uom_" + str(i)),
|
||||||
"default_warehouse": item_group!="Service" and ("Stores - " + args.get("company_abbr")) or ""
|
"default_warehouse": item_group!="Service" and ("Stores - " + args.get("company_abbr")) or ""
|
||||||
}).insert()
|
}).insert()
|
||||||
|
|
||||||
if args.get("item_img_" + str(i)):
|
if args.get("item_img_" + str(i)):
|
||||||
filename, filetype, content = args.get("item_img_" + str(i)).split(",")
|
filename, filetype, content = args.get("item_img_" + str(i)).split(",")
|
||||||
fileurl = save_file(filename, content, "Item", item, decode=True).file_name
|
fileurl = save_file(filename, content, "Item", item, decode=True).file_name
|
||||||
@@ -285,7 +285,7 @@ def create_customers(args):
|
|||||||
"territory": args.get("country"),
|
"territory": args.get("country"),
|
||||||
"company": args.get("company_name")
|
"company": args.get("company_name")
|
||||||
}).insert()
|
}).insert()
|
||||||
|
|
||||||
if args.get("customer_contact_" + str(i)):
|
if args.get("customer_contact_" + str(i)):
|
||||||
contact = args.get("customer_contact_" + str(i)).split(" ")
|
contact = args.get("customer_contact_" + str(i)).split(" ")
|
||||||
frappe.get_doc({
|
frappe.get_doc({
|
||||||
@@ -294,7 +294,7 @@ def create_customers(args):
|
|||||||
"first_name":contact[0],
|
"first_name":contact[0],
|
||||||
"last_name": len(contact) > 1 and contact[1] or ""
|
"last_name": len(contact) > 1 and contact[1] or ""
|
||||||
}).insert()
|
}).insert()
|
||||||
|
|
||||||
def create_suppliers(args):
|
def create_suppliers(args):
|
||||||
for i in xrange(1,6):
|
for i in xrange(1,6):
|
||||||
supplier = args.get("supplier_" + str(i))
|
supplier = args.get("supplier_" + str(i))
|
||||||
@@ -323,11 +323,11 @@ def create_letter_head(args):
|
|||||||
"letter_head_name": "Standard",
|
"letter_head_name": "Standard",
|
||||||
"is_default": 1
|
"is_default": 1
|
||||||
}).insert()
|
}).insert()
|
||||||
|
|
||||||
filename, filetype, content = args.get("attach_letterhead").split(",")
|
filename, filetype, content = args.get("attach_letterhead").split(",")
|
||||||
fileurl = save_file(filename, content, "Letter Head", "Standard", decode=True).file_name
|
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)
|
frappe.db.set_value("Letter Head", "Standard", "content", "<img src='%s' style='max-width: 100%%;'>" % fileurl)
|
||||||
|
|
||||||
def add_all_roles_to(name):
|
def add_all_roles_to(name):
|
||||||
user = frappe.get_doc("User", name)
|
user = frappe.get_doc("User", name)
|
||||||
for role in frappe.db.sql("""select name from tabRole"""):
|
for role in frappe.db.sql("""select name from tabRole"""):
|
||||||
@@ -348,4 +348,4 @@ def create_territories():
|
|||||||
"territory_name": name.replace("'", ""),
|
"territory_name": name.replace("'", ""),
|
||||||
"parent_territory": root_territory,
|
"parent_territory": root_territory,
|
||||||
"is_group": "No"
|
"is_group": "No"
|
||||||
}).insert()
|
}).insert()
|
||||||
|
|||||||
Reference in New Issue
Block a user