-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[IMP] make posible to call the onchange on an existing record and avoid returning computed value #1253
[IMP] make posible to call the onchange on an existing record and avoid returning computed value #1253
Conversation
…id returning computed value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (code, not tested)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
onchange_helper/models/ir_rule.py
Outdated
# If self is a record (play onchange on existing record) | ||
# we take the value of the field | ||
# If self is an empty record we will have an empty value | ||
all_values[field] = self[field] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should use convert to write to transform the record's properties into the format expected by 'new'
0fc85bb
to
bc7e474
Compare
… test and make improve play_onchange
bc7e474
to
7e5db10
Compare
…check that record have been not modify
onchange_helper/README.rst
Outdated
|
||
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... | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sebastienbeau IMO we should explain why this way to trigger the onchanges
is safe and generic....
"Behind the scene, play_onchanges
will execute all the methods registered for the list of changed fields. 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"
Make play onchange working on existing record, see documentation.