Skip to content
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

Merged
merged 5 commits into from
Jun 12, 2018

Conversation

sebastienbeau
Copy link
Member

Make play onchange working on existing record, see documentation.

Copy link

@acsonefho acsonefho left a 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)

Copy link
Contributor

@legalsylvain legalsylvain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

# 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]
Copy link
Contributor

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'

@sebastienbeau sebastienbeau force-pushed the 10.0-improve-onchange-helper branch 2 times, most recently from 0fc85bb to bc7e474 Compare June 11, 2018 23:08

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...


Copy link
Contributor

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"

@sebastienbeau sebastienbeau merged commit 21038c1 into OCA:10.0 Jun 12, 2018
EBII added a commit to EBII/server-tools that referenced this pull request Dec 11, 2018
sbejaoui pushed a commit to acsone/server-tools that referenced this pull request Dec 17, 2018
Laurent-Corron pushed a commit to acsone/server-tools that referenced this pull request Oct 18, 2019
lmignon pushed a commit to acsone/server-tools that referenced this pull request Nov 8, 2019
kevinkhao pushed a commit to akretion/server-tools that referenced this pull request Nov 23, 2020
koenloodts pushed a commit to koenloodts/server-tools that referenced this pull request Dec 14, 2021
AurelijaNorvaisaite pushed a commit to focusate/oca-server-tools that referenced this pull request May 6, 2022
kevinkhao pushed a commit to akretion/server-tools that referenced this pull request Nov 30, 2022
BT-atornero pushed a commit to BT-atornero/server-tools that referenced this pull request Jan 18, 2023
john-herholz-dt pushed a commit to DeineTuer-GmbH/OCA_server-tools that referenced this pull request Jan 11, 2024
PieterPaulussen pushed a commit to The-O-Team/server-tools that referenced this pull request Jul 18, 2024
thienvh332 pushed a commit to thienvh332/server-tools that referenced this pull request Sep 26, 2024
thienvh332 pushed a commit to thienvh332/server-tools that referenced this pull request Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants