This question has been flagged
2 Replies
5364 Views

In Odoo Version:

Am trying to call the write method of different object in one of the Button functionality persent in Other Object...

In Earlier version, whenever a write method is called, either manually or systematically irrespective of Values list, all the Functional fields present in that object will be recomputed again.... Whereas in this version it is not happening.. Any idea why it is so, or am i missing something...

Let me take classic example:

In Sale Object: [in which a button is placed]

 def button_method(self):
       ....

      self.lead_id.write({})

So when button is triggered in Sale Object, along with other functionality, it will just call a dummy write for Lead in order to trigger the functional fields present in Lead object... which works perfectly in Earlier Version, including V8 Alpha but not in Odoo V8

Note:

  • If I manage to pass a values for Write method, then it triggers the Functional field
  • And this code works great in older version...
  • functional field is not having dependency property also

 

Avatar
Discard
Author Best Answer

Well finally I got the solution... what I missed to realize was for One2many objects, write method was not triggering to compute the stored functional fields..

Solution: updated my context with "recompute"..  here it goes like this

context = dict(context, recompute=True)

when I updated my context value for "recompute" as True, everything worked fine, recomputed all my stored functional fields...

Follow the link for more details:

  1. Compute field is broken creating o2m field to database

  2. stored func fields computation on one2many write

This explains the behaviour....

Avatar
Discard

recompute=True did not work for me unfortuanetely :( : I write to the field price_unit sale.order.line but after the write the functional field price_subtotal was not recalculated? Did i miss a thing?