-
Notifications
You must be signed in to change notification settings - Fork 103
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
[16.0][IMP] shopinvader_api_sale_loyalty: do not update rewards when reading a sale #1543
base: 16.0
Are you sure you want to change the base?
[16.0][IMP] shopinvader_api_sale_loyalty: do not update rewards when reading a sale #1543
Conversation
I think so. Yet, if you install |
8836c13
to
58c2b41
Compare
I updated the PR |
claimable_rewards = odoo_rec._get_claimable_rewards() | ||
if not odoo_rec.state == "done" and not claimable_rewards.items(): |
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.
After think twice, I think we can simply remove the call to _update_programs_and_rewards
I just test it with this PR : #1552 and the test are green
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.
Thank @sebastienbeau for your work, I have included them into this PR (code, description, title). Could you close this PR to make sure all improvements are in one place
@QuocDuong1306 can you make the modification ? |
58c2b41
to
0e4a21c
Compare
This PR has been updated including changes in this PR @simahawk @cyrilmanuel |
This PR has the |
1 similar comment
This PR has the |
/ocabot merge patch |
1 similar comment
/ocabot merge patch |
On my way to merge this fine PR! |
Hey, thanks for contributing! Proceeding to merge this for you. |
@sebastienbeau your merge command was aborted due to failed check(s), which you can inspect on this commit of 16.0-ocabot-merge-pr-1543-by-sebastienbeau-bump-patch. After fixing the problem, you can re-issue a merge command. Please refrain from merging manually as it will most probably make the target branch red. |
The issue:
Context:
sale.order:_update_programs_and_rewards()
must be called at least once to create reward linesIn odoo native, it is done when clicking on button
PROMOTIONS
and onsale.order:action_confirm()
In oca, we have module
sale_loyalty_auto_refresh
([16.0][MIG] sale_loyalty_auto_refresh: Migration to 16.0 OCA/sale-promotion#208) to do it whenever the sale order is updatedSo in
shopinvader_api_sale_loyalty
,sale.order:_update_programs_and_rewards()
was explicitly called on GET /sales to make sure reward lines are created before returning the requested sale orders dataBut
sale.order:_update_programs_and_rewards()
implementation calls write() through _reset_loyalty() which is not what we expect from a GET endpoint (should be read-only); one direct consequence is that GET /sales endpoint can fail when called for locked ordersThis PR fixes it by calling
sale.order:_update_programs_and_rewards()
only when strictly needed (when no reward line exists), and of course only if not locked.Improvements: