feat: add create customer button to member
This commit is contained in:
parent
9e3776e001
commit
97a316c09a
@ -29,6 +29,14 @@ frappe.ui.form.on('Member', {
|
|||||||
frappe.set_route('query-report', 'Accounts Receivable', {member:frm.doc.name});
|
frappe.set_route('query-report', 'Accounts Receivable', {member:frm.doc.name});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!frm.doc.customer) {
|
||||||
|
frm.add_custom_button(__('Create Customer'), () => {
|
||||||
|
frm.call('make_customer_and_link').then(() => {
|
||||||
|
frm.reload_doc();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// indicator
|
// indicator
|
||||||
erpnext.utils.set_party_dashboard_indicators(frm);
|
erpnext.utils.set_party_dashboard_indicators(frm);
|
||||||
|
|
||||||
|
@ -53,6 +53,19 @@ class Member(Document):
|
|||||||
|
|
||||||
return subscription
|
return subscription
|
||||||
|
|
||||||
|
def make_customer_and_link(self):
|
||||||
|
if self.customer:
|
||||||
|
frappe.msgprint(_("A customer is already linked to this Member"))
|
||||||
|
cust = create_customer(frappe._dict({
|
||||||
|
'fullname': self.member_name,
|
||||||
|
'email': self.email_id or self.user,
|
||||||
|
'phone': None
|
||||||
|
}))
|
||||||
|
|
||||||
|
self.customer = cust
|
||||||
|
self.save()
|
||||||
|
|
||||||
|
|
||||||
def get_or_create_member(user_details):
|
def get_or_create_member(user_details):
|
||||||
member_list = frappe.get_all("Member", filters={'email': user_details.email, 'membership_type': user_details.plan_id})
|
member_list = frappe.get_all("Member", filters={'email': user_details.email, 'membership_type': user_details.plan_id})
|
||||||
if member_list and member_list[0]:
|
if member_list and member_list[0]:
|
||||||
@ -83,8 +96,10 @@ def create_customer(user_details):
|
|||||||
try:
|
try:
|
||||||
contact = frappe.new_doc("Contact")
|
contact = frappe.new_doc("Contact")
|
||||||
contact.first_name = user_details.fullname
|
contact.first_name = user_details.fullname
|
||||||
contact.add_phone(user_details.mobile, is_primary_phone=1, is_primary_mobile_no=1)
|
if user_details.mobile:
|
||||||
contact.add_email(user_details.email, is_primary=1)
|
contact.add_phone(user_details.mobile, is_primary_phone=1, is_primary_mobile_no=1)
|
||||||
|
if user_details.email:
|
||||||
|
contact.add_email(user_details.email, is_primary=1)
|
||||||
contact.insert(ignore_permissions=True)
|
contact.insert(ignore_permissions=True)
|
||||||
|
|
||||||
contact.append("links", {
|
contact.append("links", {
|
||||||
|
@ -120,13 +120,15 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "webhook_payload",
|
"fieldname": "webhook_payload",
|
||||||
"fieldtype": "Code",
|
"fieldtype": "Code",
|
||||||
|
"hidden": 1,
|
||||||
"label": "Webhook Payload",
|
"label": "Webhook Payload",
|
||||||
"options": "JSON",
|
"options": "JSON",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"index_web_pages_for_search": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2020-04-06 14:29:33.856060",
|
"modified": "2020-07-27 14:28:11.532696",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Non Profit",
|
"module": "Non Profit",
|
||||||
"name": "Membership",
|
"name": "Membership",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user