Salutation and Gender in Lead and Customer (#9199)

This commit is contained in:
KanchanChauhan 2017-06-13 15:26:35 +05:30 committed by Rushabh Mehta
parent 797f2030f8
commit 1dc26b127b
18 changed files with 173 additions and 43 deletions

View File

@ -7,7 +7,7 @@ import frappe
from frappe import _
from frappe.model.document import Document
from frappe.utils import cstr, cint
from frappe.geo.doctype.address.address import get_default_address
from frappe.contacts.doctype.address.address import get_default_address
class IncorrectCustomerGroup(frappe.ValidationError): pass
class IncorrectSupplierType(frappe.ValidationError): pass

View File

@ -9,8 +9,8 @@ from frappe import _, msgprint, scrub
from frappe.defaults import get_user_permissions
from frappe.utils import add_days, getdate, formatdate, get_first_day, date_diff, \
add_years, get_timestamp, nowdate, flt
from frappe.geo.doctype.address.address import get_address_display, get_default_address
from frappe.email.doctype.contact.contact import get_contact_details, get_default_contact
from frappe.contacts.doctype.address.address import get_address_display, get_default_address
from frappe.contacts.doctype.contact.contact import get_contact_details, get_default_contact
from erpnext.exceptions import PartyFrozen, InvalidCurrency, PartyDisabled, InvalidAccountCurrency
from erpnext.accounts.utils import get_fiscal_year
from erpnext import get_default_currency

View File

@ -25,12 +25,12 @@ frappe.ui.form.on("Supplier", {
}
if (frm.doc.__islocal) {
hide_field(['address_html', 'contact_html']);
frappe.geo.clear_address_and_contact(frm);
hide_field(['address_html','contact_html']);
frappe.contacts.clear_address_and_contact(frm);
}
else {
unhide_field(['address_html', 'contact_html']);
frappe.geo.render_address_and_contact(frm);
unhide_field(['address_html','contact_html']);
frappe.contacts.render_address_and_contact(frm);
// custom buttons
frm.add_custom_button(__('Accounting Ledger'), function () {

View File

@ -6,7 +6,7 @@ import frappe
import frappe.defaults
from frappe import msgprint, _
from frappe.model.naming import make_autoname
from frappe.geo.address_and_contact import load_address_and_contact, delete_contact_and_address
from frappe.contacts.address_and_contact import load_address_and_contact, delete_contact_and_address
from erpnext.utilities.transaction_base import TransactionBase
from erpnext.accounts.party import validate_party_accounts, get_dashboard_info, get_timeline_data # keep this

View File

@ -35,10 +35,10 @@ erpnext.LeadController = frappe.ui.form.Controller.extend({
cur_frm.page.set_inner_btn_group_as_primary(__("Make"));
}
if(!doc.__islocal) {
frappe.geo.render_address_and_contact(cur_frm);
if(!this.frm.doc.__islocal) {
frappe.contacts.render_address_and_contact(cur_frm);
} else {
frappe.geo.clear_address_and_contact(cur_frm);
frappe.contacts.clear_address_and_contact(cur_frm);
}
},

View File

@ -1,5 +1,6 @@
{
"allow_copy": 0,
"allow_guest_to_view": 0,
"allow_import": 1,
"allow_rename": 0,
"autoname": "naming_series:",
@ -71,6 +72,36 @@
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "salutation",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Salutation",
"length": 0,
"no_copy": 0,
"options": "Salutation",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
@ -106,21 +137,21 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "company_name",
"fieldtype": "Data",
"fieldname": "gender",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Organization Name",
"label": "Gender",
"length": 0,
"no_copy": 0,
"oldfieldname": "company_name",
"oldfieldtype": "Data",
"options": "Gender",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
@ -254,6 +285,36 @@
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "company_name",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Organization Name",
"length": 0,
"no_copy": 0,
"oldfieldname": "company_name",
"oldfieldtype": "Data",
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
@ -1037,6 +1098,7 @@
"unique": 0
}
],
"has_web_view": 0,
"hide_heading": 0,
"hide_toolbar": 0,
"icon": "fa fa-user",
@ -1044,15 +1106,15 @@
"image_field": "image",
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2017-02-22 18:53:16.231035",
"modified": "2017-04-10 13:06:36.324439",
"modified_by": "Administrator",
"module": "CRM",
"name": "Lead",
"name_case": "Title Case",
"owner": "Administrator",
"permissions": [
{

View File

@ -8,7 +8,7 @@ from frappe.utils import (cstr, validate_email_add, cint, comma_and, has_gravata
from frappe.model.mapper import get_mapped_doc
from erpnext.controllers.selling_controller import SellingController
from frappe.geo.address_and_contact import load_address_and_contact
from frappe.contacts.address_and_contact import load_address_and_contact
from erpnext.accounts.party import set_taxes
sender_field = "email_id"

View File

@ -146,7 +146,7 @@ doc_events = {
"on_cancel": "erpnext.stock.doctype.material_request.material_request.update_completed_and_requested_qty"
},
"User": {
"after_insert": "frappe.email.doctype.contact.contact.update_contact",
"after_insert": "frappe.contacts.doctype.contact.contact.update_contact",
"validate": "erpnext.hr.doctype.employee.employee.validate_employee_role",
"on_update": ["erpnext.hr.doctype.employee.employee.update_user_permissions",
"erpnext.portal.utils.set_default_role"]

View File

@ -106,7 +106,7 @@
"collapsible": 0,
"columns": 0,
"fieldname": "salutation",
"fieldtype": "Select",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
@ -119,7 +119,7 @@
"no_copy": 0,
"oldfieldname": "salutation",
"oldfieldtype": "Select",
"options": "\nMr\nMs",
"options": "Salutation",
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
@ -404,7 +404,7 @@
"collapsible": 0,
"columns": 0,
"fieldname": "gender",
"fieldtype": "Select",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
@ -417,7 +417,7 @@
"no_copy": 0,
"oldfieldname": "gender",
"oldfieldtype": "Select",
"options": "\nMale\nFemale\nOther",
"options": "Gender",
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
@ -2353,10 +2353,11 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2017-03-14 17:04:27.247238",
"modified": "2017-07-10 13:08:15.826832",
"modified_by": "Administrator",
"module": "HR",
"name": "Employee",
"name_case": "Title Case",
"owner": "Administrator",
"permissions": [
{

View File

@ -24,7 +24,7 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
this.frm.set_query("shipping_address", function() {
if(me.frm.doc.customer) {
return {
query: 'frappe.geo.doctype.address.address.address_query',
query: 'frappe.contacts.doctype.address.address.address_query',
filters: { link_doctype: 'Customer', link_name: me.frm.doc.customer }
};
} else

View File

@ -50,7 +50,7 @@ $.extend(erpnext.queries, {
}
return {
query: 'frappe.email.doctype.contact.contact.contact_query',
query: 'frappe.contacts.doctype.contact.contact.contact_query',
filters: { link_doctype: frappe.dynamic_link.doctype, link_name: doc[frappe.dynamic_link.fieldname] } };
}
},
@ -63,14 +63,14 @@ $.extend(erpnext.queries, {
}
return {
query: 'frappe.geo.doctype.address.address.address_query',
query: 'frappe.contacts.doctype.address.address.address_query',
filters: { link_doctype: frappe.dynamic_link.doctype, link_name: doc[frappe.dynamic_link.fieldname] } };
}
},
company_address_query: function(doc) {
return {
query: 'frappe.geo.doctype.address.address.address_query',
query: 'frappe.contacts.doctype.address.address.address_query',
filters: { is_your_company_address: 1, link_doctype: 'Company', link_name: doc.company || '' }
};
},

View File

@ -80,7 +80,7 @@ erpnext.utils.get_address_display = function(frm, address_field, display_field,
if(!display_field) display_field = "address_display";
if(frm.doc[address_field]) {
frappe.call({
method: "frappe.geo.doctype.address.address.get_address_display",
method: "frappe.contacts.doctype.address.address.get_address_display",
args: {"address_dict": frm.doc[address_field] },
callback: function(r) {
if(r.message) {
@ -144,7 +144,7 @@ erpnext.utils.get_contact_details = function(frm) {
if(frm.doc["contact_person"]) {
frappe.call({
method: "frappe.email.doctype.contact.contact.get_contact_details",
method: "frappe.contacts.doctype.contact.contact.get_contact_details",
args: {contact: frm.doc.contact_person },
callback: function(r) {
if(r.message)
@ -166,7 +166,7 @@ erpnext.utils.validate_mandatory = function(frm, label, value, trigger_on) {
erpnext.utils.get_shipping_address = function(frm, callback){
frappe.call({
method: "frappe.geo.doctype.address.address.get_shipping_address",
method: "frappe.contacts.doctype.address.address.get_shipping_address",
args: {company: frm.doc.company},
callback: function(r){
if(r.message){

View File

@ -37,7 +37,7 @@ frappe.ui.form.on("Customer", {
frm.toggle_display(['address_html','contact_html'], !frm.doc.__islocal);
if(!frm.doc.__islocal) {
frappe.geo.render_address_and_contact(frm);
frappe.contacts.render_address_and_contact(frm);
// custom buttons
frm.add_custom_button(__('Accounting Ledger'), function() {
@ -53,7 +53,7 @@ frappe.ui.form.on("Customer", {
erpnext.utils.set_party_dashboard_indicators(frm);
} else {
frappe.geo.clear_address_and_contact(frm);
frappe.contacts.clear_address_and_contact(frm);
}
var grid = cur_frm.get_field("sales_team").grid;

View File

@ -77,6 +77,36 @@
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "salutation",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Salutation",
"length": 0,
"no_copy": 0,
"options": "Salutation",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 1,
"collapsible": 0,
@ -108,6 +138,36 @@
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "gender",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Gender",
"length": 0,
"no_copy": 0,
"options": "Gender",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,

View File

@ -9,8 +9,8 @@ import frappe.defaults
from frappe.utils import flt, cint, cstr
from frappe.desk.reportview import build_match_conditions
from erpnext.utilities.transaction_base import TransactionBase
from frappe.geo.address_and_contact import load_address_and_contact, delete_contact_and_address
from erpnext.accounts.party import validate_party_accounts, get_dashboard_info, get_timeline_data # keep this
from erpnext.accounts.party import validate_party_accounts, get_dashboard_info # keep this
from frappe.contacts.address_and_contact import load_address_and_contact, delete_contact_and_address
class Customer(TransactionBase):
def get_feed(self):
@ -88,11 +88,18 @@ class Customer(TransactionBase):
address.append('links', dict(link_doctype='Customer', link_name=self.name))
address.save()
lead = frappe.db.get_value("Lead", self.lead_name, ["lead_name", "email_id", "phone", "mobile_no"], as_dict=True)
lead = frappe.db.get_value("Lead", self.lead_name, ["lead_name", "email_id", "phone", "mobile_no", "gender", "salutation"], as_dict=True)
lead.lead_name = lead.lead_name.split(" ")
lead.first_name = lead.lead_name[0]
lead.last_name = " ".join(lead.lead_name[1:])
# create contact from lead
contact = frappe.new_doc('Contact')
contact.first_name = lead.lead_name
contact.first_name = lead.first_name
contact.last_name = lead.last_name
contact.gender = lead.gender
contact.salutation = lead.salutation
contact.email_id = lead.email_id
contact.phone = lead.phone
contact.mobile_no = lead.mobile_no

View File

@ -7,11 +7,11 @@ frappe.ui.form.on('Sales Partner', {
if(frm.doc.__islocal){
hide_field(['address_html', 'contact_html', 'address_contacts']);
frappe.geo.clear_address_and_contact(frm);
frappe.contacts.clear_address_and_contact(frm);
}
else{
unhide_field(['address_html', 'contact_html', 'address_contacts']);
frappe.geo.render_address_and_contact(frm);
frappe.contacts.render_address_and_contact(frm);
}
}
});

View File

@ -5,7 +5,7 @@ from __future__ import unicode_literals
import frappe
from frappe.utils import cstr, filter_strip_join
from frappe.website.website_generator import WebsiteGenerator
from frappe.geo.address_and_contact import load_address_and_contact
from frappe.contacts.address_and_contact import load_address_and_contact
class SalesPartner(WebsiteGenerator):
website = frappe._dict(

View File

@ -6,7 +6,7 @@ import frappe
from frappe import throw, _
import frappe.defaults
from frappe.utils import cint, flt, get_fullname, cstr
from frappe.geo.doctype.address.address import get_address_display
from frappe.contacts.doctype.address.address import get_address_display
from erpnext.shopping_cart.doctype.shopping_cart_settings.shopping_cart_settings import get_shopping_cart_settings
from frappe.utils.nestedset import get_root_of
from erpnext.accounts.utils import get_account_name