Can't get prompt data from client side into python

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) {
                {'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) {
                    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).

def make_opportunity(source_name, sales_data, target_doc=None):
    def set_missing_values(source, target):
        target.ignore_pricing_rule = 1
        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

Thanks for any help!

Try debugging via your console.

Are the request parameters passed okay?

The console is just showing the traceback and a HTTP 500 error - so I guess they are not getting passed right?