feat: provision to create customer from opportunity (#27141)

* feat: provision to create customer from opportunity

* fead: linking of address and contact

* revert: create_opportunity_address_contact

* enabming print hide and no copy
This commit is contained in:
Anupam Kumar 2021-08-25 19:18:17 +05:30 committed by GitHub
parent 60675379c2
commit 4d98be2126
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 3 deletions

View File

@ -95,9 +95,17 @@ frappe.ui.form.on("Opportunity", {
}, __('Create'));
}
frm.add_custom_button(__('Quotation'),
cur_frm.cscript.create_quotation, __('Create'));
if (frm.doc.opportunity_from != "Customer") {
frm.add_custom_button(__('Customer'),
function() {
frm.trigger("make_customer")
}, __('Create'));
}
frm.add_custom_button(__('Quotation'),
function() {
frm.trigger("create_quotation")
}, __('Create'));
}
if(!frm.doc.__islocal && frm.perm[0].write && frm.doc.docstatus==0) {
@ -195,6 +203,13 @@ erpnext.crm.Opportunity = class Opportunity extends frappe.ui.form.Controller {
frm: cur_frm
})
}
make_customer() {
frappe.model.open_mapped_doc({
method: "erpnext.crm.doctype.opportunity.opportunity.make_customer",
frm: cur_frm
})
}
};
extend_cscript(cur_frm.cscript, new erpnext.crm.Opportunity({frm: cur_frm}));

View File

@ -287,6 +287,24 @@ def make_request_for_quotation(source_name, target_doc=None):
return doclist
@frappe.whitelist()
def make_customer(source_name, target_doc=None):
def set_missing_values(source, target):
if source.opportunity_from == "Lead":
target.lead_name = source.party_name
doclist = get_mapped_doc("Opportunity", source_name, {
"Opportunity": {
"doctype": "Customer",
"field_map": {
"currency": "default_currency",
"customer_name": "customer_name"
}
}
}, target_doc, set_missing_values)
return doclist
@frappe.whitelist()
def make_supplier_quotation(source_name, target_doc=None):
doclist = get_mapped_doc("Opportunity", source_name, {

View File

@ -20,6 +20,7 @@
"tax_withholding_category",
"default_bank_account",
"lead_name",
"opportunity_name",
"image",
"column_break0",
"account_manager",
@ -493,6 +494,14 @@
"fieldtype": "Link",
"label": "Tax Withholding Category",
"options": "Tax Withholding Category"
},
{
"fieldname": "opportunity_name",
"fieldtype": "Link",
"label": "From Opportunity",
"no_copy": 1,
"options": "Opportunity",
"print_hide": 1
}
],
"icon": "fa fa-user",
@ -500,7 +509,7 @@
"image_field": "image",
"index_web_pages_for_search": 1,
"links": [],
"modified": "2021-01-28 12:54:57.258959",
"modified": "2021-08-25 18:56:09.929905",
"modified_by": "Administrator",
"module": "Selling",
"name": "Customer",