-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[FIX] sale_exception: add a register_hook to prevent other action_con… #3767
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
base: 18.0
Are you sure you want to change the base?
Conversation
…firm being executed if there is an exception rule
0ca6919 to
e59a03b
Compare
|
@lav-adhoc Could you explain again the use case you have and what actions that are not protected by transactions are concerned ? |
|
@rousseldenis This video demonstrates the issue (version 16) Before this PR, if a sale was not confirmed due to an exception, the loyalty program would still be applied. Although the problem occurs with coupons, it's possible that new problems might also arise with payment integrations or electronic invoicing. |
|
@rousseldenis We don't consider the solution of creating bridge modules to be viable, as it would require developing an additional module for each combination of independent modules that perform a specific action (such as assigning points in sale_loyalty). We believe this is the best solution, as it decouples the behavior from the installation order of the modules. It would also work for any case, not just loyalty. Lastly, the tests are failing, but the issue is unrelated to this implementation and comes from other modules. |
|
Ok, I have a concern about the method used (like before). IMHO, in fact, that's because your functional need is: if there are exceptions, keep them but don't add coupons. Then, in What do you think ? |
|
@rousseldenis , you're right that we could add a mechanism to prevent coupons from being created. Our primary concern, however, lies with the design of the module. From our perspective, if an exception occurs, everything executed before the super() call should be rolled back. This means if sale_exception halts a method's flow, the Sale Order should remain unmodified. The current behavior is inconsistent with how Odoo typically handles exceptions. We've explored various possibilities, such as creating a new exception type in the ORM that triggers a rollback and write exception data via another database pointer. However, all these solutions would require a significant refactor of the module. While @lav-adhoc 's proposal is somewhat of a "hack," it currently appears to be the least invasive way to address this module's issue. |
|
Hi @rousseldenis what do you think about @maq-adhoc 's comment? |
|
@lav-adhoc Thanks for the PR I stumbled on the same issue while having sale_exception and OdooEE sale_subscription module installed, but I'm not sure if this "hack" is the right solution, because we can't rely on proper MRO between modules having no dependencies between each other. IMO as @maq-adhoc mentioned, an exception must be raised in the Anyway, I would suggest to move forward and merge this PR for the time being until we can find a better solution, but could you please do the following:
Eventually you could mention my PR #3885 as a possible way to solve this, but as expressed, I guess the refactor will have to be more consequent 😓 EDIT: Actually, this didn't fix my issue with #3837 integrated into the patched function. I'll get back to it next week |
|
Hello, I agree this is a general issue of this module and the glue module stuff for me is not good enough. When a module override the _action_confirm, it can only expects its action are either rollbacked in case of exception, either commit if the sale order is confirmed, but commited without the SO validation, can only leads to weird cases. Between the multiple PR around this, this one seems to do the job. I would also be in favor on merging this until #3885 is completed. |
…firm being executed if there is an exception rule.
For example, if a coupon was used, a point would be added, and then upon confirming the sale, it would be added again.
The issue is in the sale_loyalty module, where the loyalty program is computed before the sale is confirmed in this line
This video demonstrates the issue (version 16), because in the version 16 there is the same problem. We decided to apply the fix in version 18, since version 16 is a stable.
https://drive.google.com/file/d/1qeEYlVVqXb8MOJq7BybVe4EaYtiDcIPS/view
Before this PR, if a sale was not confirmed due to an exception, the loyalty program would still be applied.
Although the problem occurs with coupons, it's possible that new problems might also arise with payment integrations or electronic invoicing.