[refactor] address and contact list in customer, supplier, lead, sales person
This commit is contained in:
parent
b1fdbf2335
commit
7d36875d6f
@ -1,8 +1,6 @@
|
|||||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
{% include 'setup/doctype/contact_control/contact_control.js' %};
|
|
||||||
|
|
||||||
cur_frm.cscript.refresh = function(doc, dt, dn) {
|
cur_frm.cscript.refresh = function(doc, dt, dn) {
|
||||||
cur_frm.cscript.make_dashboard(doc);
|
cur_frm.cscript.make_dashboard(doc);
|
||||||
|
|
||||||
@ -17,9 +15,8 @@ cur_frm.cscript.refresh = function(doc, dt, dn) {
|
|||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
unhide_field(['address_html','contact_html']);
|
unhide_field(['address_html','contact_html']);
|
||||||
// make lists
|
|
||||||
cur_frm.cscript.make_address(doc,dt,dn);
|
erpnext.utils.render_address_and_contact(cur_frm)
|
||||||
cur_frm.cscript.make_contact(doc,dt,dn);
|
|
||||||
|
|
||||||
cur_frm.communication_view = new frappe.views.CommunicationList({
|
cur_frm.communication_view = new frappe.views.CommunicationList({
|
||||||
parent: cur_frm.fields_dict.communication_html.wrapper,
|
parent: cur_frm.fields_dict.communication_html.wrapper,
|
||||||
@ -60,45 +57,6 @@ cur_frm.cscript.make_dashboard = function(doc) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cur_frm.cscript.make_address = function() {
|
|
||||||
if(!cur_frm.address_list) {
|
|
||||||
cur_frm.address_list = new frappe.ui.Listing({
|
|
||||||
parent: cur_frm.fields_dict['address_html'].wrapper,
|
|
||||||
page_length: 5,
|
|
||||||
new_doctype: "Address",
|
|
||||||
get_query: function() {
|
|
||||||
return "select name, address_type, address_line1, address_line2, city, state, country, pincode, fax, email_id, phone, is_primary_address, is_shipping_address from tabAddress where supplier='" +
|
|
||||||
cur_frm.doc.name.replace(/'/g, "\\'") + "' and docstatus != 2 order by is_primary_address desc"
|
|
||||||
},
|
|
||||||
as_dict: 1,
|
|
||||||
no_results_message: __('No addresses created'),
|
|
||||||
render_row: cur_frm.cscript.render_address_row,
|
|
||||||
});
|
|
||||||
// note: render_address_row is defined in contact_control.js
|
|
||||||
}
|
|
||||||
cur_frm.address_list.run();
|
|
||||||
}
|
|
||||||
|
|
||||||
cur_frm.cscript.make_contact = function() {
|
|
||||||
if(!cur_frm.contact_list) {
|
|
||||||
cur_frm.contact_list = new frappe.ui.Listing({
|
|
||||||
parent: cur_frm.fields_dict['contact_html'].wrapper,
|
|
||||||
page_length: 5,
|
|
||||||
new_doctype: "Contact",
|
|
||||||
get_query: function() {
|
|
||||||
return "select name, first_name, last_name, email_id, phone, mobile_no, department, designation, is_primary_contact from tabContact where supplier='" +
|
|
||||||
cur_frm.doc.name.replace(/'/g, "\\'") + "' and docstatus != 2 order by is_primary_contact desc"
|
|
||||||
},
|
|
||||||
as_dict: 1,
|
|
||||||
no_results_message: __('No contacts created'),
|
|
||||||
render_row: cur_frm.cscript.render_contact_row,
|
|
||||||
});
|
|
||||||
// note: render_contact_row is defined in contact_control.js
|
|
||||||
}
|
|
||||||
cur_frm.contact_list.run();
|
|
||||||
}
|
|
||||||
|
|
||||||
cur_frm.fields_dict['default_price_list'].get_query = function(doc, cdt, cdn) {
|
cur_frm.fields_dict['default_price_list'].get_query = function(doc, cdt, cdn) {
|
||||||
return{
|
return{
|
||||||
filters:{'buying': 1}
|
filters:{'buying': 1}
|
||||||
|
@ -9,10 +9,14 @@ from frappe.utils import cint
|
|||||||
from frappe import msgprint, _
|
from frappe import msgprint, _
|
||||||
from frappe.model.naming import make_autoname
|
from frappe.model.naming import make_autoname
|
||||||
from erpnext.accounts.party import create_party_account
|
from erpnext.accounts.party import create_party_account
|
||||||
|
from erpnext.utilities.address_and_contact import load_address_and_contact
|
||||||
|
|
||||||
from erpnext.utilities.transaction_base import TransactionBase
|
from erpnext.utilities.transaction_base import TransactionBase
|
||||||
|
|
||||||
class Supplier(TransactionBase):
|
class Supplier(TransactionBase):
|
||||||
|
def onload(self):
|
||||||
|
"""Load address and contacts in `__onload`"""
|
||||||
|
load_address_and_contact(self, "supplier")
|
||||||
|
|
||||||
def autoname(self):
|
def autoname(self):
|
||||||
supp_master_name = frappe.defaults.get_global_default('supp_master_name')
|
supp_master_name = frappe.defaults.get_global_default('supp_master_name')
|
||||||
|
@ -88,3 +88,4 @@ execute:frappe.delete_doc("DocType", "Purchase Request Item")
|
|||||||
erpnext.patches.v4_2.recalculate_bom_cost
|
erpnext.patches.v4_2.recalculate_bom_cost
|
||||||
erpnext.patches.v4_2.fix_gl_entries_for_stock_transactions
|
erpnext.patches.v4_2.fix_gl_entries_for_stock_transactions
|
||||||
erpnext.patches.v4_2.update_requested_and_ordered_qty
|
erpnext.patches.v4_2.update_requested_and_ordered_qty
|
||||||
|
execute:frappe.delete_doc("DocType", "Contact Control")
|
||||||
|
@ -10,6 +10,8 @@
|
|||||||
"public/js/feature_setup.js",
|
"public/js/feature_setup.js",
|
||||||
"public/js/utils.js",
|
"public/js/utils.js",
|
||||||
"public/js/queries.js",
|
"public/js/queries.js",
|
||||||
"public/js/utils/party.js"
|
"public/js/utils/party.js",
|
||||||
|
"public/js/templates/address_list.html",
|
||||||
|
"public/js/templates/contact_list.html"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -81,5 +81,28 @@ $.extend(erpnext, {
|
|||||||
|
|
||||||
d.show();
|
d.show();
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
erpnext.utils = {
|
||||||
|
render_address_and_contact: function(frm) {
|
||||||
|
// render address
|
||||||
|
$(frm.fields_dict['address_html'].wrapper)
|
||||||
|
.html(frappe.render(frappe.templates.address_list,
|
||||||
|
cur_frm.doc.__onload))
|
||||||
|
.find(".btn-address").on("click", function() {
|
||||||
|
new_doc("Address");
|
||||||
|
});
|
||||||
|
|
||||||
|
// render contact
|
||||||
|
if(frm.fields_dict['contact_html']) {
|
||||||
|
$(frm.fields_dict['contact_html'].wrapper)
|
||||||
|
.html(frappe.render(frappe.templates.contact_list,
|
||||||
|
cur_frm.doc.__onload))
|
||||||
|
.find(".btn-contact").on("click", function() {
|
||||||
|
new_doc("Contact");
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
{% include 'setup/doctype/contact_control/contact_control.js' %};
|
|
||||||
|
|
||||||
cur_frm.cscript.onload = function(doc, dt, dn) {
|
cur_frm.cscript.onload = function(doc, dt, dn) {
|
||||||
cur_frm.cscript.load_defaults(doc, dt, dn);
|
cur_frm.cscript.load_defaults(doc, dt, dn);
|
||||||
}
|
}
|
||||||
@ -32,8 +30,8 @@ cur_frm.cscript.refresh = function(doc, dt, dn) {
|
|||||||
}else{
|
}else{
|
||||||
unhide_field(['address_html','contact_html']);
|
unhide_field(['address_html','contact_html']);
|
||||||
// make lists
|
// make lists
|
||||||
cur_frm.cscript.make_address(doc, dt, dn);
|
|
||||||
cur_frm.cscript.make_contact(doc, dt, dn);
|
erpnext.utils.render_address_and_contact(cur_frm)
|
||||||
|
|
||||||
cur_frm.communication_view = new frappe.views.CommunicationList({
|
cur_frm.communication_view = new frappe.views.CommunicationList({
|
||||||
parent: cur_frm.fields_dict.communication_html.wrapper,
|
parent: cur_frm.fields_dict.communication_html.wrapper,
|
||||||
@ -79,44 +77,6 @@ cur_frm.cscript.setup_dashboard = function(doc) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.cscript.make_address = function() {
|
|
||||||
if(!cur_frm.address_list) {
|
|
||||||
cur_frm.address_list = new frappe.ui.Listing({
|
|
||||||
parent: cur_frm.fields_dict['address_html'].wrapper,
|
|
||||||
page_length: 5,
|
|
||||||
new_doctype: "Address",
|
|
||||||
get_query: function() {
|
|
||||||
return "select name, address_type, address_line1, address_line2, city, state, country, pincode, fax, email_id, phone, is_primary_address, is_shipping_address from tabAddress where customer='" +
|
|
||||||
cur_frm.doc.name.replace(/'/g, "\\'") + "' and docstatus != 2 order by is_primary_address desc"
|
|
||||||
},
|
|
||||||
as_dict: 1,
|
|
||||||
no_results_message: __('No addresses created'),
|
|
||||||
render_row: cur_frm.cscript.render_address_row,
|
|
||||||
});
|
|
||||||
// note: render_address_row is defined in contact_control.js
|
|
||||||
}
|
|
||||||
cur_frm.address_list.run();
|
|
||||||
}
|
|
||||||
|
|
||||||
cur_frm.cscript.make_contact = function() {
|
|
||||||
if(!cur_frm.contact_list) {
|
|
||||||
cur_frm.contact_list = new frappe.ui.Listing({
|
|
||||||
parent: cur_frm.fields_dict['contact_html'].wrapper,
|
|
||||||
page_length: 5,
|
|
||||||
new_doctype: "Contact",
|
|
||||||
get_query: function() {
|
|
||||||
return "select name, first_name, last_name, email_id, phone, mobile_no, department, designation, is_primary_contact from tabContact where customer='" +
|
|
||||||
cur_frm.doc.name.replace(/'/g, "\\'") + "' and docstatus != 2 order by is_primary_contact desc"
|
|
||||||
},
|
|
||||||
as_dict: 1,
|
|
||||||
no_results_message: __('No contacts created'),
|
|
||||||
render_row: cur_frm.cscript.render_contact_row,
|
|
||||||
});
|
|
||||||
// note: render_contact_row is defined in contact_control.js
|
|
||||||
}
|
|
||||||
cur_frm.contact_list.run();
|
|
||||||
}
|
|
||||||
|
|
||||||
cur_frm.fields_dict['customer_group'].get_query = function(doc, dt, dn) {
|
cur_frm.fields_dict['customer_group'].get_query = function(doc, dt, dn) {
|
||||||
return{
|
return{
|
||||||
filters:{'is_group': 'No'}
|
filters:{'is_group': 'No'}
|
||||||
|
@ -7,11 +7,14 @@ from frappe.model.naming import make_autoname
|
|||||||
from frappe import msgprint, _
|
from frappe import msgprint, _
|
||||||
import frappe.defaults
|
import frappe.defaults
|
||||||
|
|
||||||
|
|
||||||
from erpnext.utilities.transaction_base import TransactionBase
|
from erpnext.utilities.transaction_base import TransactionBase
|
||||||
|
from erpnext.utilities.address_and_contact import load_address_and_contact
|
||||||
from erpnext.accounts.party import create_party_account
|
from erpnext.accounts.party import create_party_account
|
||||||
|
|
||||||
class Customer(TransactionBase):
|
class Customer(TransactionBase):
|
||||||
|
def onload(self):
|
||||||
|
"""Load address and contacts in `__onload`"""
|
||||||
|
load_address_and_contact(self, "customer")
|
||||||
|
|
||||||
def autoname(self):
|
def autoname(self):
|
||||||
cust_master_name = frappe.defaults.get_global_default('cust_master_name')
|
cust_master_name = frappe.defaults.get_global_default('cust_master_name')
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
{% include 'setup/doctype/contact_control/contact_control.js' %};
|
|
||||||
|
|
||||||
frappe.provide("erpnext");
|
frappe.provide("erpnext");
|
||||||
erpnext.LeadController = frappe.ui.form.Controller.extend({
|
erpnext.LeadController = frappe.ui.form.Controller.extend({
|
||||||
setup: function() {
|
setup: function() {
|
||||||
@ -42,7 +40,7 @@ erpnext.LeadController = frappe.ui.form.Controller.extend({
|
|||||||
});
|
});
|
||||||
|
|
||||||
if(!this.frm.doc.__islocal) {
|
if(!this.frm.doc.__islocal) {
|
||||||
this.make_address_list();
|
erpnext.utils.render_address_and_contact(cur_frm);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -9,11 +9,13 @@ from frappe import session
|
|||||||
from frappe.model.mapper import get_mapped_doc
|
from frappe.model.mapper import get_mapped_doc
|
||||||
|
|
||||||
from erpnext.controllers.selling_controller import SellingController
|
from erpnext.controllers.selling_controller import SellingController
|
||||||
|
from erpnext.utilities.address_and_contact import load_address_and_contact
|
||||||
|
|
||||||
class Lead(SellingController):
|
class Lead(SellingController):
|
||||||
def onload(self):
|
def onload(self):
|
||||||
customer = frappe.db.get_value("Customer", {"lead_name": self.name})
|
customer = frappe.db.get_value("Customer", {"lead_name": self.name})
|
||||||
self.get("__onload").is_customer = customer
|
self.get("__onload").is_customer = customer
|
||||||
|
load_address_and_contact(self, "lead")
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self._prev = frappe._dict({
|
self._prev = frappe._dict({
|
||||||
|
@ -1 +0,0 @@
|
|||||||
[To deprecate] Common scripts for Contacts.
|
|
@ -1 +0,0 @@
|
|||||||
from __future__ import unicode_literals
|
|
@ -1,161 +0,0 @@
|
|||||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
|
||||||
// License: GNU General Public License v3. See license.txt
|
|
||||||
|
|
||||||
if(cur_frm.fields_dict['territory']) {
|
|
||||||
cur_frm.fields_dict['territory'].get_query = function(doc, dt, dn) {
|
|
||||||
return {
|
|
||||||
filters: {
|
|
||||||
'is_group': "No"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cur_frm.cscript.render_contact_row = function(wrapper, data) {
|
|
||||||
// prepare data
|
|
||||||
data.fullname = (data.first_name || '')
|
|
||||||
+ (data.last_name ? ' ' + data.last_name : '');
|
|
||||||
data.primary = data.is_primary_contact ? ' [Primary]' : '';
|
|
||||||
|
|
||||||
// prepare description
|
|
||||||
var description = [];
|
|
||||||
$.each([
|
|
||||||
['phone', 'Tel'],
|
|
||||||
['mobile_no', 'Mobile'],
|
|
||||||
['email_id', 'Email'],
|
|
||||||
['department', 'Department'],
|
|
||||||
['designation', 'Designation']],
|
|
||||||
function(i, v) {
|
|
||||||
if(v[0] && data[v[0]]) {
|
|
||||||
description.push(repl('<h6>%(label)s:</h6> %(value)s', {
|
|
||||||
label: v[1],
|
|
||||||
value: data[v[0]],
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
data.description = description.join('<br />');
|
|
||||||
|
|
||||||
cur_frm.cscript.render_row_in_wrapper(wrapper, data, 'Contact');
|
|
||||||
}
|
|
||||||
|
|
||||||
cur_frm.cscript.render_address_row = function(wrapper, data) {
|
|
||||||
// prepare data
|
|
||||||
data.fullname = data.address_type;
|
|
||||||
data.primary = '';
|
|
||||||
if (data.is_primary_address) data.primary += ' [Preferred for Billing]';
|
|
||||||
if (data.is_shipping_address) data.primary += ' [Preferred for Shipping]';
|
|
||||||
|
|
||||||
// prepare address
|
|
||||||
var address = [];
|
|
||||||
$.each(['address_line1', 'address_line2', 'city', 'state', 'country', 'pincode'],
|
|
||||||
function(i, v) {
|
|
||||||
if(data[v]) address.push(data[v]);
|
|
||||||
});
|
|
||||||
|
|
||||||
data.address = address.join('<br />');
|
|
||||||
data.address = "<p class='address-list'>" + data.address + "</p>";
|
|
||||||
|
|
||||||
// prepare description
|
|
||||||
var description = [];
|
|
||||||
$.each([
|
|
||||||
['address', 'Address'],
|
|
||||||
['phone', 'Tel'],
|
|
||||||
['fax', 'Fax'],
|
|
||||||
['email_id', 'Email']],
|
|
||||||
function(i, v) {
|
|
||||||
if(data[v[0]]) {
|
|
||||||
description.push(repl('<h6>%(label)s:</h6> %(value)s', {
|
|
||||||
label: v[1],
|
|
||||||
value: data[v[0]],
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
data.description = description.join('<br />');
|
|
||||||
|
|
||||||
cur_frm.cscript.render_row_in_wrapper(wrapper, data, 'Address');
|
|
||||||
|
|
||||||
$(wrapper).find('p.address-list').css({
|
|
||||||
'padding-left': '10px',
|
|
||||||
'margin-bottom': '-10px'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
cur_frm.cscript.render_row_in_wrapper = function(wrapper, data, doctype) {
|
|
||||||
// render
|
|
||||||
var $wrapper = $(wrapper);
|
|
||||||
|
|
||||||
data.doctype = doctype.toLowerCase();
|
|
||||||
|
|
||||||
$wrapper.append(repl("\
|
|
||||||
<h4><a class='link_type'>%(fullname)s</a>%(primary)s</h4>\
|
|
||||||
<div class='description'>\
|
|
||||||
<p>%(description)s</p>\
|
|
||||||
<p><a class='delete link_type'>delete this %(doctype)s</a></p>\
|
|
||||||
</div>", data));
|
|
||||||
|
|
||||||
// make link
|
|
||||||
$wrapper.find('h4 a.link_type').click(function() {
|
|
||||||
loaddoc(doctype, data.name);
|
|
||||||
});
|
|
||||||
|
|
||||||
// css
|
|
||||||
$wrapper.css({ 'margin': '0px' });
|
|
||||||
$wrapper.find('div.description').css({
|
|
||||||
'padding': '5px 2px',
|
|
||||||
'line-height': '150%',
|
|
||||||
});
|
|
||||||
$wrapper.find('h6').css({ 'display': 'inline-block' });
|
|
||||||
|
|
||||||
// show delete
|
|
||||||
var $delete_doc = $wrapper.find('a.delete');
|
|
||||||
if (frappe.model.can_delete(doctype))
|
|
||||||
$delete_doc.toggle(true);
|
|
||||||
else
|
|
||||||
$delete_doc.toggle(false);
|
|
||||||
|
|
||||||
$delete_doc.css({ 'padding-left': '0px' });
|
|
||||||
|
|
||||||
$delete_doc.click(function() {
|
|
||||||
cur_frm.cscript.delete_doc(doctype, data.name);
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
cur_frm.cscript.delete_doc = function(doctype, name) {
|
|
||||||
// confirm deletion
|
|
||||||
var go_ahead = confirm(__("Delete {0} {1}?", [doctype, name]));
|
|
||||||
if (!go_ahead) return;
|
|
||||||
|
|
||||||
frappe.model.delete_doc(doctype, name, function(r) {
|
|
||||||
if (!r.exc) {
|
|
||||||
var list_name = doctype.toLowerCase() + '_list';
|
|
||||||
cur_frm[list_name].run();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Render List
|
|
||||||
cur_frm.cscript.render_list = function(doc, doctype, wrapper, ListView, make_new_doc) {
|
|
||||||
frappe.model.with_doctype(doctype, function(r) {
|
|
||||||
if((r && r['403']) || frappe.boot.user.all_read.indexOf(doctype)===-1) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var RecordListView = frappe.views.RecordListView.extend({
|
|
||||||
default_docstatus: ['0', '1', '2'],
|
|
||||||
default_filters: [
|
|
||||||
[doctype, doc.doctype.toLowerCase().replace(" ", "_"), '=', doc.name],
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
if (make_new_doc) {
|
|
||||||
RecordListView = RecordListView.extend({
|
|
||||||
make_new_doc: make_new_doc,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
var record_list_view = new RecordListView(doctype, wrapper, ListView);
|
|
||||||
if (!cur_frm[doctype.toLowerCase().replace(" ", "_") + "_list"]) {
|
|
||||||
cur_frm[doctype.toLowerCase().replace(" ", "_") + "_list"] = record_list_view;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
{
|
|
||||||
"creation": "2012-03-27 14:36:19.000000",
|
|
||||||
"docstatus": 0,
|
|
||||||
"doctype": "DocType",
|
|
||||||
"fields": [
|
|
||||||
{
|
|
||||||
"fieldname": "header",
|
|
||||||
"fieldtype": "Text",
|
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "Header",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"fieldname": "customer_intro",
|
|
||||||
"fieldtype": "Text",
|
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "Customer Intro",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"fieldname": "supplier_intro",
|
|
||||||
"fieldtype": "Text",
|
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "Supplier Intro",
|
|
||||||
"permlevel": 0
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"idx": 1,
|
|
||||||
"in_create": 1,
|
|
||||||
"issingle": 1,
|
|
||||||
"modified": "2013-12-20 19:23:02.000000",
|
|
||||||
"modified_by": "Administrator",
|
|
||||||
"module": "Setup",
|
|
||||||
"name": "Contact Control",
|
|
||||||
"owner": "Administrator",
|
|
||||||
"permissions": [
|
|
||||||
{
|
|
||||||
"create": 0,
|
|
||||||
"email": 1,
|
|
||||||
"permlevel": 0,
|
|
||||||
"print": 1,
|
|
||||||
"read": 1,
|
|
||||||
"role": "System Manager",
|
|
||||||
"write": 1
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"read_only": 1
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
|
||||||
# License: GNU General Public License v3. See license.txt
|
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
import frappe
|
|
||||||
|
|
||||||
from frappe.model.document import Document
|
|
||||||
|
|
||||||
class ContactControl(Document):
|
|
||||||
pass
|
|
@ -1,12 +1,6 @@
|
|||||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
{% include 'setup/doctype/contact_control/contact_control.js' %};
|
|
||||||
|
|
||||||
cur_frm.cscript.onload = function(doc,dt,dn){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
cur_frm.cscript.refresh = function(doc,dt,dn){
|
cur_frm.cscript.refresh = function(doc,dt,dn){
|
||||||
|
|
||||||
if(doc.__islocal){
|
if(doc.__islocal){
|
||||||
@ -15,8 +9,8 @@ cur_frm.cscript.refresh = function(doc,dt,dn){
|
|||||||
else{
|
else{
|
||||||
unhide_field(['address_html', 'contact_html']);
|
unhide_field(['address_html', 'contact_html']);
|
||||||
// make lists
|
// make lists
|
||||||
cur_frm.cscript.make_address(doc,dt,dn);
|
|
||||||
cur_frm.cscript.make_contact(doc,dt,dn);
|
erpnext.utils.render_address_and_contact(cur_frm)
|
||||||
|
|
||||||
if (doc.show_in_website) {
|
if (doc.show_in_website) {
|
||||||
cur_frm.set_intro(__("Published on website at: {0}",
|
cur_frm.set_intro(__("Published on website at: {0}",
|
||||||
@ -25,57 +19,6 @@ cur_frm.cscript.refresh = function(doc,dt,dn){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cur_frm.cscript.make_address = function() {
|
|
||||||
if(!cur_frm.address_list) {
|
|
||||||
cur_frm.address_list = new frappe.ui.Listing({
|
|
||||||
parent: cur_frm.fields_dict['address_html'].wrapper,
|
|
||||||
page_length: 2,
|
|
||||||
new_doctype: "Address",
|
|
||||||
custom_new_doc: function(doctype) {
|
|
||||||
var address = frappe.model.make_new_doc_and_get_name('Address');
|
|
||||||
address = locals['Address'][address];
|
|
||||||
address.sales_partner = cur_frm.doc.name;
|
|
||||||
address.address_title = cur_frm.doc.name;
|
|
||||||
address.address_type = "Office";
|
|
||||||
frappe.set_route("Form", "Address", address.name);
|
|
||||||
},
|
|
||||||
get_query: function() {
|
|
||||||
return "select name, address_type, address_line1, address_line2, city, state, country, pincode, fax, email_id, phone, is_primary_address, is_shipping_address from tabAddress where sales_partner='" +
|
|
||||||
cur_frm.doc.name.replace(/'/g, "\\'") + "' and docstatus != 2 order by is_primary_address desc"
|
|
||||||
},
|
|
||||||
as_dict: 1,
|
|
||||||
no_results_message: __('No addresses created'),
|
|
||||||
render_row: cur_frm.cscript.render_address_row,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
cur_frm.address_list.run();
|
|
||||||
}
|
|
||||||
|
|
||||||
cur_frm.cscript.make_contact = function() {
|
|
||||||
if(!cur_frm.contact_list) {
|
|
||||||
cur_frm.contact_list = new frappe.ui.Listing({
|
|
||||||
parent: cur_frm.fields_dict['contact_html'].wrapper,
|
|
||||||
page_length: 2,
|
|
||||||
new_doctype: "Contact",
|
|
||||||
custom_new_doc: function(doctype) {
|
|
||||||
var contact = frappe.model.make_new_doc_and_get_name('Contact');
|
|
||||||
contact = locals['Contact'][contact];
|
|
||||||
contact.sales_partner = cur_frm.doc.name;
|
|
||||||
frappe.set_route("Form", "Contact", contact.name);
|
|
||||||
},
|
|
||||||
get_query: function() {
|
|
||||||
return "select name, first_name, last_name, email_id, phone, mobile_no, department, designation, is_primary_contact from tabContact where sales_partner='" +
|
|
||||||
cur_frm.doc.name.replace(/'/g, "\\'") + "' and docstatus != 2 order by is_primary_contact desc"
|
|
||||||
},
|
|
||||||
as_dict: 1,
|
|
||||||
no_results_message: __('No contacts created'),
|
|
||||||
render_row: cur_frm.cscript.render_contact_row,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
cur_frm.contact_list.run();
|
|
||||||
}
|
|
||||||
|
|
||||||
cur_frm.fields_dict['partner_target_details'].grid.get_field("item_group").get_query = function(doc, dt, dn) {
|
cur_frm.fields_dict['partner_target_details'].grid.get_field("item_group").get_query = function(doc, dt, dn) {
|
||||||
return{
|
return{
|
||||||
filters:{ 'is_group': "No" }
|
filters:{ 'is_group': "No" }
|
||||||
|
@ -5,11 +5,16 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe.utils import cstr, filter_strip_join
|
from frappe.utils import cstr, filter_strip_join
|
||||||
from frappe.website.website_generator import WebsiteGenerator
|
from frappe.website.website_generator import WebsiteGenerator
|
||||||
|
from erpnext.utilities.address_and_contact import load_address_and_contact
|
||||||
|
|
||||||
class SalesPartner(WebsiteGenerator):
|
class SalesPartner(WebsiteGenerator):
|
||||||
page_title_field = "partner_name"
|
page_title_field = "partner_name"
|
||||||
condition_field = "show_in_website"
|
condition_field = "show_in_website"
|
||||||
template = "templates/generators/sales_partner.html"
|
template = "templates/generators/sales_partner.html"
|
||||||
|
def onload(self):
|
||||||
|
"""Load address and contacts in `__onload`"""
|
||||||
|
load_address_and_contact(self, "sales_partner")
|
||||||
|
|
||||||
def autoname(self):
|
def autoname(self):
|
||||||
self.name = self.partner_name
|
self.name = self.partner_name
|
||||||
|
|
||||||
|
@ -2,3 +2,12 @@
|
|||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
{% include 'controllers/js/contact_address_common.js' %};
|
{% include 'controllers/js/contact_address_common.js' %};
|
||||||
|
|
||||||
|
frappe.ui.form.on("Address", "validate", function(frm) {
|
||||||
|
// clear linked customer / supplier / sales partner on saving...
|
||||||
|
$.each(["Customer", "Supplier", "Sales Partner"], function(i, doctype) {
|
||||||
|
var name = frm.doc[doctype.toLowerCase().replace(/ /g, "_")];
|
||||||
|
if(name && locals[doctype] && locals[doctype][name])
|
||||||
|
frappe.model.remove_from_locals(doctype, name);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
@ -3,6 +3,15 @@
|
|||||||
|
|
||||||
{% include 'controllers/js/contact_address_common.js' %};
|
{% include 'controllers/js/contact_address_common.js' %};
|
||||||
|
|
||||||
|
frappe.ui.form.on("Contact", "validate", function(frm) {
|
||||||
|
// clear linked customer / supplier / sales partner on saving...
|
||||||
|
$.each(["Customer", "Supplier", "Sales Partner"], function(i, doctype) {
|
||||||
|
var name = frm.doc[doctype.toLowerCase().replace(/ /g, "_")];
|
||||||
|
if(name && locals[doctype] && locals[doctype][name])
|
||||||
|
frappe.model.remove_from_locals(doctype, name);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
cur_frm.cscript.refresh = function(doc) {
|
cur_frm.cscript.refresh = function(doc) {
|
||||||
cur_frm.communication_view = new frappe.views.CommunicationList({
|
cur_frm.communication_view = new frappe.views.CommunicationList({
|
||||||
list: frappe.get_list("Communication", {"parent": doc.name, "parenttype": "Contact"}),
|
list: frappe.get_list("Communication", {"parent": doc.name, "parenttype": "Contact"}),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user