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

[16.0][IMP] sale_loyalty_order_suggestion: Add hook method #205

Merged

Conversation

pilarvargas-tecnativa
Copy link
Contributor

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

@OCA-git-bot
Copy link
Contributor

Hi @chienandalu,
some modules you are maintaining are being modified, check this out!

@pedrobaeza pedrobaeza added this to the 16.0 milestone Mar 14, 2024
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(
Copy link
Member

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?

Copy link
Contributor Author

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.

image

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
@pilarvargas-tecnativa pilarvargas-tecnativa force-pushed the 16.0-imp-sale_loyalty_order_suggestion branch from c34f07d to 3671951 Compare March 15, 2024 15:48
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.
@pedrobaeza
Copy link
Member

/ocabot merge patch

@OCA-git-bot
Copy link
Contributor

On my way to merge this fine PR!
Prepared branch 16.0-ocabot-merge-pr-205-by-pedrobaeza-bump-patch, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 731930f into OCA:16.0 Mar 20, 2024
6 of 7 checks passed
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 1ddb190. Thanks a lot for contributing to OCA. ❤️

@pedrobaeza pedrobaeza deleted the 16.0-imp-sale_loyalty_order_suggestion branch March 20, 2024 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants