[UPD] - Update documentation
parent
afbb98f5af
commit
59aa3e02bb
|
@ -22,6 +22,14 @@ class Base(models.AbstractModel):
|
|||
|
||||
@api.model
|
||||
def play_onchanges(self, values, onchange_fields):
|
||||
"""
|
||||
:param values: dict of input value that
|
||||
:param onchange_fields: fields for which onchange methods will be
|
||||
played
|
||||
Order in onchange_fields is very important as onchanges methods will
|
||||
be played in that order.
|
||||
:return: changed values
|
||||
"""
|
||||
# _onchange_spec() will return onchange fields from the default view
|
||||
# we need all fields in the dict even the empty ones
|
||||
# otherwise 'onchange()' will not apply changes to them
|
||||
|
|
|
@ -31,3 +31,9 @@ You can also use it on existing record for example:
|
|||
Then the onchange will be played with the vals passed and the existing vals of the sale. `vals` will be updated with partner_invoice_id, pricelist_id, etc..
|
||||
|
||||
Behind the scene, `play_onchanges` will execute **all the methods** registered for the list of changed fields, so you do not have to call manually each onchange. To avoid performance issue when the method is called on a record, the record will be transformed into a memory record before calling the registered methods to avoid to trigger SQL updates command when values are assigned to the record by the onchange
|
||||
|
||||
|
||||
Notes:
|
||||
|
||||
- Order in onchange_fields is very important as onchanges methods will be played in that order.
|
||||
- If you use memory object in `vals`, be award that onchange method in base model call `self.invalidate_cache()` that reset it.
|
||||
|
|
Loading…
Reference in New Issue