This question has been flagged
1053 Views

I have installed sale, crm, sale_crm module.

Now in sales order, there a opportunity_id field is present.

My requirement is:

Whenever there is a change in sales order's total amount(amount_total), its corresponding opportunity's 'expected revenue' should be updated.

My code is:


@api.onchange('amount_total')
def onchange_amount_total(self):

      for rec in self:
            if rec.amount_total:
               rec.opportunity_id.planned_revenue = rec.amount_total



Also i tried:


     @api.onchange('amount_total')
     def onchange_amount_total(self):

           self.opportunity_id.planned_revenue = self.amount_total


What was the issue in my code. please help?



Avatar
Discard