[minor] Added 'Invite User' in Contact
This commit is contained in:
parent
80d2a55342
commit
73e73795f1
@ -218,9 +218,13 @@ erpnext.patches.v6_4.fix_status_in_sales_and_purchase_order
|
|||||||
erpnext.patches.v6_4.fix_modified_in_sales_order_and_purchase_order
|
erpnext.patches.v6_4.fix_modified_in_sales_order_and_purchase_order
|
||||||
erpnext.patches.v6_4.fix_duplicate_bins
|
erpnext.patches.v6_4.fix_duplicate_bins
|
||||||
erpnext.patches.v6_4.fix_sales_order_maintenance_status
|
erpnext.patches.v6_4.fix_sales_order_maintenance_status
|
||||||
|
<<<<<<< HEAD
|
||||||
erpnext.patches.v6_4.email_digest_update
|
erpnext.patches.v6_4.email_digest_update
|
||||||
|
|
||||||
# delete shopping cart doctypes
|
# delete shopping cart doctypes
|
||||||
execute:frappe.delete_doc_if_exists("DocType", "Applicable Territory")
|
execute:frappe.delete_doc_if_exists("DocType", "Applicable Territory")
|
||||||
execute:frappe.delete_doc_if_exists("DocType", "Shopping Cart Price List")
|
execute:frappe.delete_doc_if_exists("DocType", "Shopping Cart Price List")
|
||||||
execute:frappe.delete_doc_if_exists("DocType", "Shopping Cart Taxes and Charges Master")
|
execute:frappe.delete_doc_if_exists("DocType", "Shopping Cart Taxes and Charges Master")
|
||||||
|
=======
|
||||||
|
erpnext.patches.v6_4.set_user_in_contact
|
||||||
|
>>>>>>> [minor] Added 'Invite User' in Contact
|
||||||
|
5
erpnext/patches/v6_4/set_user_in_contact.py
Normal file
5
erpnext/patches/v6_4/set_user_in_contact.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import frappe
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
frappe.db.sql("""update tabContact, tabUser set tabContact.user = tabUser.name
|
||||||
|
where tabContact.email_id = tabUser.email""")
|
@ -4,11 +4,28 @@
|
|||||||
{% include 'controllers/js/contact_address_common.js' %};
|
{% include 'controllers/js/contact_address_common.js' %};
|
||||||
|
|
||||||
cur_frm.email_field = "email_id";
|
cur_frm.email_field = "email_id";
|
||||||
frappe.ui.form.on("Contact", "validate", function(frm) {
|
frappe.ui.form.on("Contact", {
|
||||||
|
refresh: function(frm) {
|
||||||
|
if(!frm.doc.user && !frm.is_new() && frm.perm[0].write) {
|
||||||
|
frm.add_custom_button(__("Invite as User"), function() {
|
||||||
|
frappe.call({
|
||||||
|
method: "erpnext.utilities.doctype.contact.contact.invite_user",
|
||||||
|
args: {
|
||||||
|
contact: frm.doc.name
|
||||||
|
},
|
||||||
|
callback: function(r) {
|
||||||
|
frm.set_value("user", r.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
validate: function(frm) {
|
||||||
// clear linked customer / supplier / sales partner on saving...
|
// clear linked customer / supplier / sales partner on saving...
|
||||||
$.each(["Customer", "Supplier", "Sales Partner"], function(i, doctype) {
|
$.each(["Customer", "Supplier", "Sales Partner"], function(i, doctype) {
|
||||||
var name = frm.doc[doctype.toLowerCase().replace(/ /g, "_")];
|
var name = frm.doc[doctype.toLowerCase().replace(/ /g, "_")];
|
||||||
if(name && locals[doctype] && locals[doctype][name])
|
if(name && locals[doctype] && locals[doctype][name])
|
||||||
frappe.model.remove_from_locals(doctype, name);
|
frappe.model.remove_from_locals(doctype, name);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
@ -80,22 +80,23 @@
|
|||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"fieldname": "user",
|
"fieldname": "email_id",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Data",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
"in_filter": 0,
|
"in_filter": 0,
|
||||||
"in_list_view": 0,
|
"in_list_view": 0,
|
||||||
"label": "User Id",
|
"label": "Email Id",
|
||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"options": "User",
|
"oldfieldname": "email_id",
|
||||||
|
"oldfieldtype": "Data",
|
||||||
|
"options": "Email",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"precision": "",
|
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"search_index": 0,
|
"search_index": 1,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
@ -143,30 +144,6 @@
|
|||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"fieldname": "email_id",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"hidden": 0,
|
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_list_view": 0,
|
|
||||||
"label": "Email Id",
|
|
||||||
"no_copy": 0,
|
|
||||||
"oldfieldname": "email_id",
|
|
||||||
"oldfieldtype": "Data",
|
|
||||||
"options": "Email",
|
|
||||||
"permlevel": 0,
|
|
||||||
"print_hide": 0,
|
|
||||||
"read_only": 0,
|
|
||||||
"report_hide": 0,
|
|
||||||
"reqd": 0,
|
|
||||||
"search_index": 1,
|
|
||||||
"set_only_once": 0,
|
|
||||||
"unique": 0
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
@ -212,6 +189,29 @@
|
|||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"fieldname": "user",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"in_filter": 0,
|
||||||
|
"in_list_view": 0,
|
||||||
|
"label": "User Id",
|
||||||
|
"no_copy": 0,
|
||||||
|
"options": "User",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"unique": 0
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
@ -494,7 +494,7 @@
|
|||||||
"is_submittable": 0,
|
"is_submittable": 0,
|
||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"modified": "2015-10-07 00:26:20.667566",
|
"modified": "2015-10-07 00:38:08.152183",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Utilities",
|
"module": "Utilities",
|
||||||
"name": "Contact",
|
"name": "Contact",
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.utils import cstr, extract_email_id
|
from frappe.utils import cstr
|
||||||
|
|
||||||
from erpnext.controllers.status_updater import StatusUpdater
|
from erpnext.controllers.status_updater import StatusUpdater
|
||||||
|
|
||||||
@ -22,6 +22,11 @@ class Contact(StatusUpdater):
|
|||||||
def validate(self):
|
def validate(self):
|
||||||
self.set_status()
|
self.set_status()
|
||||||
self.validate_primary_contact()
|
self.validate_primary_contact()
|
||||||
|
self.set_user()
|
||||||
|
|
||||||
|
def set_user(self):
|
||||||
|
if not self.user and self.email_id:
|
||||||
|
self.user = frappe.db.get_value("User", {"email": self.email_id})
|
||||||
|
|
||||||
def validate_primary_contact(self):
|
def validate_primary_contact(self):
|
||||||
if self.is_primary_contact == 1:
|
if self.is_primary_contact == 1:
|
||||||
@ -53,6 +58,21 @@ class Contact(StatusUpdater):
|
|||||||
frappe.db.sql("""update `tabIssue` set contact='' where contact=%s""",
|
frappe.db.sql("""update `tabIssue` set contact='' where contact=%s""",
|
||||||
self.name)
|
self.name)
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def invite_user(contact):
|
||||||
|
contact = frappe.get_doc("Contact", contact)
|
||||||
|
if contact.has_permission("write"):
|
||||||
|
user = frappe.get_doc({
|
||||||
|
"doctype": "User",
|
||||||
|
"first_name": contact.first_name,
|
||||||
|
"last_name": contact.last_name,
|
||||||
|
"email": contact.email_id,
|
||||||
|
"user_type": "Website User",
|
||||||
|
"send_welcome_email": 1
|
||||||
|
}).insert(ignore_permissions = True)
|
||||||
|
|
||||||
|
return user.name
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_contact_details(contact):
|
def get_contact_details(contact):
|
||||||
contact = frappe.get_doc("Contact", contact)
|
contact = frappe.get_doc("Contact", contact)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user