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

* 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

(cherry picked from commit 4d98be2126)

# Conflicts:
#	erpnext/crm/doctype/opportunity/opportunity.js

* Update opportunity.js

* fix: conflicts

Co-authored-by: Anupam Kumar <anupamvns0099@gmail.com>
Co-authored-by: Rucha Mahabal <ruchamahabal2@gmail.com>
This commit is contained in:
Frappe PR Bot
2021-08-25 20:05:54 +05:30
committed by GitHub
parent 4c3034ad79
commit f8ec0b6a86
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) {
@@ -194,6 +202,13 @@ erpnext.crm.Opportunity = frappe.ui.form.Controller.extend({
method: "erpnext.crm.doctype.opportunity.opportunity.make_quotation",
frm: cur_frm
})
},
make_customer: function() {
frappe.model.open_mapped_doc({
method: "erpnext.crm.doctype.opportunity.opportunity.make_customer",
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",