Open QuocDuong1306 opened 6 months ago
- Would it be a good addition to add a new POST route in the module to explicitly call
sale.order:_update_programs_and_rewards()
?
I think so. Yet, if you install sale_loyalty_auto_refresh
this won't be needed AFAIU. If yes, we should simply mention this in the readme.
I updated the PR
@QuocDuong1306 can you make the modification ?
This PR has been updated including changes in this PR @simahawk @cyrilmanuel
This PR has the approved
label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖
This PR has the approved
label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖
/ocabot merge patch
/ocabot merge patch
On my way to merge this fine PR! Prepared branch 16.0-ocabot-merge-pr-1543-by-sebastienbeau-bump-patch, awaiting test results.
Hey, thanks for contributing! Proceeding to merge this for you. Prepared branch 16.0-ocabot-merge-pr-1543-by-sebastienbeau-bump-patch, awaiting test results.
@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
(https://github.com/OCA/sale-promotion/pull/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: