Update/send data to another doctype

I am looking for an pobibility to update data in a linked doctype.

Example:
We are collecting all information about the (possible) order in CRM=>Opportunity
If the Opportunity is converted (approved) customer are doing all the sales calculation in an aditional craftsmanship software.

To track the invoices and payment we are creating a Sales Invoice fetching all the informations from Opportunity. This is working well.

What I want to do:
Step 1: send Sales Invoice date to Opportunity to have the info also there.
Step 2: set status of Opportunity to “closed”, if Sales Invoice is payed.

Please help me to find a way to solve this.

br
Andreas

When a sales invoice is submitted, use the on_submit doc_events (server script) to update all information in the opportunity and close the opportunity.

1 Like

Step 1 is working, but step two Unfortunately not

My code is simple, and it’s working woth DocType Event “After Submit”,
but non of the other DocType Events are working if I am submitting a payment to the invoice. The Invoice is set to “Paid” but the script is not running.

frappe.db.set_value("Opportunity",doc.custom_anf_nr,{
            'custom_reid' : doc.name,
            'custom_verrechnung_datum' : doc.posting_date,
            'custom_wwre_nr' : doc.custom_wwre_nr,
            'custom_wwre_netto' : doc.total,
            'status' : 'Replied'
        })

if doc.status == "Paid" :  
    frappe.db.set_value("Opportunity",doc.custom_anf_nr,{
        'status' : 'Closed'
        })

pls, could someone help me with this?

br
Andreas

You have to check the update_status logic in the sales invoice/payment entry, because when payment entry submit with full payment then run the update_status

there is no update in DocType Event, or I am thinging the wrong way?

br
Andreas

Yes, please check this.