[minor] [enhance] fixes #6222
This commit is contained in:
parent
e35dbca01b
commit
bd15e31ea1
@ -2,6 +2,19 @@
|
|||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
frappe.ui.form.on("Supplier", {
|
frappe.ui.form.on("Supplier", {
|
||||||
|
setup: function(frm) {
|
||||||
|
frm.set_query('default_price_list', { 'buying': 1});
|
||||||
|
frm.set_query('account', 'accounts', function(doc, cdt, cdn) {
|
||||||
|
var d = locals[cdt][cdn];
|
||||||
|
return {
|
||||||
|
filters: {
|
||||||
|
'account_type': 'Payable',
|
||||||
|
'company': d.company,
|
||||||
|
"is_group": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
refresh: function(frm) {
|
refresh: function(frm) {
|
||||||
if(frappe.defaults.get_default("supp_master_name")!="Naming Series") {
|
if(frappe.defaults.get_default("supp_master_name")!="Naming Series") {
|
||||||
frm.toggle_display("naming_series", false);
|
frm.toggle_display("naming_series", false);
|
||||||
@ -16,23 +29,14 @@ frappe.ui.form.on("Supplier", {
|
|||||||
else {
|
else {
|
||||||
unhide_field(['address_html','contact_html']);
|
unhide_field(['address_html','contact_html']);
|
||||||
erpnext.utils.render_address_and_contact(frm);
|
erpnext.utils.render_address_and_contact(frm);
|
||||||
|
|
||||||
|
frm.add_custom_button(__('Accounting Ledger'), function() {
|
||||||
|
frappe.set_route('query-report', 'General Ledger',
|
||||||
|
{party_type:'Supplier', party:frm.doc.name});
|
||||||
|
});
|
||||||
|
frm.add_custom_button(__('Accounts Payable'), function() {
|
||||||
|
frappe.set_route('query-report', 'Accounts Payable', {supplier:frm.doc.name});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
cur_frm.fields_dict['default_price_list'].get_query = function(doc, cdt, cdn) {
|
|
||||||
return{
|
|
||||||
filters:{'buying': 1}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cur_frm.fields_dict['accounts'].grid.get_field('account').get_query = function(doc, cdt, cdn) {
|
|
||||||
var d = locals[cdt][cdn];
|
|
||||||
return {
|
|
||||||
filters: {
|
|
||||||
'account_type': 'Payable',
|
|
||||||
'company': d.company,
|
|
||||||
"is_group": 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -2,64 +2,13 @@
|
|||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
frappe.ui.form.on("Customer", {
|
frappe.ui.form.on("Customer", {
|
||||||
refresh: function(frm) {
|
setup: function(frm) {
|
||||||
if(frappe.defaults.get_default("cust_master_name")!="Naming Series") {
|
frm.add_fetch('lead_name', 'company_name', 'customer_name');
|
||||||
frm.toggle_display("naming_series", false);
|
frm.add_fetch('default_sales_partner','commission_rate','default_commission_rate');
|
||||||
} else {
|
|
||||||
erpnext.toggle_naming_series();
|
|
||||||
}
|
|
||||||
|
|
||||||
frm.toggle_display(['address_html','contact_html'], !frm.doc.__islocal);
|
frm.set_query('customer_group', {'is_group': 0});
|
||||||
|
frm.set_query('default_price_list', { 'selling': 1});
|
||||||
if(!frm.doc.__islocal) {
|
frm.set_query('account', 'accounts', function(doc, cdt, cdn) {
|
||||||
erpnext.utils.render_address_and_contact(frm);
|
|
||||||
} else {
|
|
||||||
erpnext.utils.clear_address_and_contact(frm);
|
|
||||||
}
|
|
||||||
|
|
||||||
var grid = cur_frm.get_field("sales_team").grid;
|
|
||||||
grid.set_column_disp("allocated_amount", false);
|
|
||||||
grid.set_column_disp("incentives", false);
|
|
||||||
},
|
|
||||||
validate: function(frm) {
|
|
||||||
if(frm.doc.lead_name) frappe.model.clear_doc("Lead", frm.doc.lead_name);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
cur_frm.cscript.onload = function(doc, dt, dn) {
|
|
||||||
cur_frm.cscript.load_defaults(doc, dt, dn);
|
|
||||||
}
|
|
||||||
|
|
||||||
cur_frm.cscript.load_defaults = function(doc, dt, dn) {
|
|
||||||
doc = locals[doc.doctype][doc.name];
|
|
||||||
if(!(doc.__islocal && doc.lead_name)) { return; }
|
|
||||||
|
|
||||||
var fields_to_refresh = frappe.model.set_default_values(doc);
|
|
||||||
if(fields_to_refresh) { refresh_many(fields_to_refresh); }
|
|
||||||
}
|
|
||||||
|
|
||||||
cur_frm.add_fetch('lead_name', 'company_name', 'customer_name');
|
|
||||||
cur_frm.add_fetch('default_sales_partner','commission_rate','default_commission_rate');
|
|
||||||
|
|
||||||
cur_frm.fields_dict['customer_group'].get_query = function(doc, dt, dn) {
|
|
||||||
return{
|
|
||||||
filters:{'is_group': 0}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cur_frm.fields_dict.lead_name.get_query = function(doc, cdt, cdn) {
|
|
||||||
return{
|
|
||||||
query: "erpnext.controllers.queries.lead_query"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cur_frm.fields_dict['default_price_list'].get_query = function(doc, cdt, cdn) {
|
|
||||||
return{
|
|
||||||
filters:{'selling': 1}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cur_frm.fields_dict['accounts'].grid.get_field('account').get_query = function(doc, cdt, cdn) {
|
|
||||||
var d = locals[cdt][cdn];
|
var d = locals[cdt][cdn];
|
||||||
var filters = {
|
var filters = {
|
||||||
'account_type': 'Receivable',
|
'account_type': 'Receivable',
|
||||||
@ -74,4 +23,36 @@ cur_frm.fields_dict['accounts'].grid.get_field('account').get_query = function(d
|
|||||||
return {
|
return {
|
||||||
filters: filters
|
filters: filters
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
refresh: function(frm) {
|
||||||
|
if(frappe.defaults.get_default("cust_master_name")!="Naming Series") {
|
||||||
|
frm.toggle_display("naming_series", false);
|
||||||
|
} else {
|
||||||
|
erpnext.toggle_naming_series();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
frm.toggle_display(['address_html','contact_html'], !frm.doc.__islocal);
|
||||||
|
|
||||||
|
if(!frm.doc.__islocal) {
|
||||||
|
erpnext.utils.render_address_and_contact(frm);
|
||||||
|
|
||||||
|
frm.add_custom_button(__('Accounting Ledger'), function() {
|
||||||
|
frappe.set_route('query-report', 'General Ledger',
|
||||||
|
{party_type:'Customer', party:frm.doc.name});
|
||||||
|
});
|
||||||
|
frm.add_custom_button(__('Accounts Receivable'), function() {
|
||||||
|
frappe.set_route('query-report', 'Accounts Receivable', {customer:frm.doc.name});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
erpnext.utils.clear_address_and_contact(frm);
|
||||||
|
}
|
||||||
|
|
||||||
|
var grid = cur_frm.get_field("sales_team").grid;
|
||||||
|
grid.set_column_disp("allocated_amount", false);
|
||||||
|
grid.set_column_disp("incentives", false);
|
||||||
|
},
|
||||||
|
validate: function(frm) {
|
||||||
|
if(frm.doc.lead_name) frappe.model.clear_doc("Lead", frm.doc.lead_name);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
@ -46,9 +46,22 @@ class Customer(TransactionBase):
|
|||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.flags.is_new_doc = self.is_new()
|
self.flags.is_new_doc = self.is_new()
|
||||||
|
self.flags.old_lead = self.lead_name
|
||||||
validate_party_accounts(self)
|
validate_party_accounts(self)
|
||||||
self.status = get_party_status(self)
|
self.status = get_party_status(self)
|
||||||
|
|
||||||
|
def on_update(self):
|
||||||
|
self.validate_name_with_customer_group()
|
||||||
|
|
||||||
|
if self.flags.old_lead != self.lead_name:
|
||||||
|
self.update_lead_status()
|
||||||
|
|
||||||
|
self.update_address()
|
||||||
|
self.update_contact()
|
||||||
|
|
||||||
|
if self.flags.is_new_doc:
|
||||||
|
self.create_lead_address_contact()
|
||||||
|
|
||||||
def update_lead_status(self):
|
def update_lead_status(self):
|
||||||
'''If Customer created from Lead, update lead status to "Converted"
|
'''If Customer created from Lead, update lead status to "Converted"
|
||||||
update Customer link in Quotation, Opportunity'''
|
update Customer link in Quotation, Opportunity'''
|
||||||
@ -88,15 +101,6 @@ class Customer(TransactionBase):
|
|||||||
if not frappe.db.exists("Contact", c.name):
|
if not frappe.db.exists("Contact", c.name):
|
||||||
c.insert()
|
c.insert()
|
||||||
|
|
||||||
def on_update(self):
|
|
||||||
self.validate_name_with_customer_group()
|
|
||||||
|
|
||||||
self.update_address()
|
|
||||||
self.update_contact()
|
|
||||||
|
|
||||||
if self.flags.is_new_doc:
|
|
||||||
self.create_lead_address_contact()
|
|
||||||
|
|
||||||
def validate_name_with_customer_group(self):
|
def validate_name_with_customer_group(self):
|
||||||
if frappe.db.exists("Customer Group", self.name):
|
if frappe.db.exists("Customer Group", self.name):
|
||||||
frappe.throw(_("A Customer Group exists with same name please change the Customer name or rename the Customer Group"), frappe.NameError)
|
frappe.throw(_("A Customer Group exists with same name please change the Customer name or rename the Customer Group"), frappe.NameError)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user