-
-
Notifications
You must be signed in to change notification settings - Fork 63
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] sale_loyalty_order_suggestion: Add hook method #205
[16.0][IMP] sale_loyalty_order_suggestion: Add hook method #205
Conversation
Hi @chienandalu, |
def _filter_programs_by_rules_with_products(self): | ||
"""Hook method. The objective of this method is to filter by rules that establish | ||
products as criteria in a loyalty program and then in other methods make the | ||
filtering that corresponds to each functionality.""" | ||
valid_programs = self._get_available_programs() | ||
# Filters programs that have rules with minimum_qty > 0 | ||
programs_with_minimum_qty = valid_programs.filtered( |
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.
Why this module includes this minimum quantity criteria?
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.
The purpose of this module is to suggest promotions on order lines whose product is part of the rules of a promotion.
When the suggestion is made, it shows a gift icon which, when clicked, allows us to configure what is necessary for the promotion to be applicable (products and quantity to be added to the sales order).
By default, promotions in their rules consider the domain [ ] for the allowed products if a specific product is not set in their rules.
The rules of a promotion are not restrictive to each other but as soon as one is fulfilled, the promotion is applicable.
For this reason, and following the example of the DEMO promotion "Buy 3 large cabinets, get one for free" of the type "Buy X get Y", for a promotion to have its rules based on products, it is necessary to establish a quantity as the main criterion.
The rest of the types of promotions can also base their rules on products and that is why in this logic they are filtered by product quantity.
It should be clarified that the different types of promotions facilitate a more direct configuration (giving the configuration practically done) of the rules, but in reality we can configure anything as we need.
Add hook method to help communicate this module with other modules that extend it by returning records from programs whose rules are based on products before filtering by order product and avoid extra modules that will not provide any functionality. TT48349
c34f07d
to
3671951
Compare
Since we cannot know which rule is being approved for the promotion to be applicable, in case of multi-rules it may be necessary to have available the product that makes the promotion suggestion in order to filter the first rule that complies with that product.
/ocabot merge patch |
On my way to merge this fine PR! |
Congratulations, your PR was merged at 1ddb190. Thanks a lot for contributing to OCA. ❤️ |
Add hook method to help communicate this module with other modules that extend it by returning records from programs whose rules are based on products before filtering by order product and avoid extra modules that will not provide any functionality.
cc @Tecnativa TT48349
@chienandalu @pedrobaeza please review