Hi all,
I have a script running to be able to create an opportunity from a sales order (we have a lot of repeat business). The code is below:
make_opportunity: function(doc, cdt, cdn) {
frappe.prompt([
{'default': doc.owner, 'fieldname': 'contact_by', 'fieldtype': 'Link', 'label': 'Owner',
'options': 'Sales Person', 'reqd': 1},
{'fieldname': 'contact_date', 'fieldtype': 'Date', 'label': 'Next Contact', 'reqd': 1}
],
function(data) {
frappe.model.open_mapped_doc({
method: "erpnext.selling.custom_methods.make_opportunity",
frm: cur_frm,
sales_data: data
})
},
'Create Opportunity'
)
},
The problem is that the data does not get through to the python function, which is below. It works as intended without the sales_data variable (and of course, if sales_data is set to an optional variable. If that is the case, it always ends up as None).
@frappe.whitelist()
def make_opportunity(source_name, sales_data, target_doc=None):
def set_missing_values(source, target):
target.ignore_pricing_rule = 1
target.run_method("set_missing_values")
target.with_items = True
target.enquiry_type = 'From Sales Order'
target_doc = get_mapped_doc("Sales Order", source_name, {
"Sales Order": {
"doctype": "Opportunity",
"validation": {
"docstatus": ["=", 1]
}
},
"Sales Order Item": {
"doctype": "Opportunity Item",
"field_map": {
"rate": "rate",
"name": "prevdoc_detail_docname",
"parent": "against_sales_order",
},
}
}, target_doc, set_missing_values)
return target_doc
doc.save()
Thanks for any help!