Skip to Content
Menu
This question has been flagged
2 Replies
2676 Views

I want my opportunity stage to change when I store or sent a quotation with an automated action.

I believe I would need to execute some python code when the status is "draft"

Could someone help me out? 


Thanks 


Jan


Avatar
Discard
Best Answer

Odoo 18.0

Create an Automation Rule that is triggered when the Quotation state is set to Quotation Sent:

Avatar
Discard
Best Answer

Hi Jan, 
I- what you want is: "When a quotation is created, the related opportunity must have the stage X."
the algorithm is pretty simple: 
1- when quotation's create funtion is triggered.
2- if field opportunity_id is not empty, then trigger lead stage change.
3- if not, standard quotation creation.

the code should be something like this: 


@api.model
def create(self, values):
rec = super(....).create(values)
    if rec.opportunity_id:
        rec.opportunity_id.stage_id = Ref to stage X
    return rec


II- If the process should be triggered while calling an automated action, then it's almost the same logic:
1- If automated action is called
2- Basically it will create quotations i assume ? 
3- you get all quotations created and say :


quotation_ids.mapped('opportunity_id').write('stage_id': Ref to stage X )


Hope this helps.
Upvote if it does.

Avatar
Discard
Author

Hi Ibrahim

I will surely try this out.

In the mean time I also found this in the forum:

https://www.odoo.com/nl_NL/forum/help-1/crm-pipeline-automation-171632

This also works!

Will keep you posted on my findings.

thx for the swift reply!

Jan