oca-pos/odoo-bringout-oca-pos-pos_loyalty_exclude/pos_loyalty_exclude/models/loyalty_rule.py
Ernad Husremovic 377f346a99 Move all OCA POS modules from oca-technical to dedicated oca-pos submodule
Reorganized 74 POS-related modules for better structure:
- Moved all odoo-bringout-oca-pos-* packages from packages/oca-technical/
- Now organized in dedicated packages/oca-pos/ submodule
- Includes payment, receipt, loyalty, order, product, and partner modules
- Maintains all module functionality while improving project organization

This creates a cleaner separation between general technical modules
and Point of Sale specific functionality.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-30 17:15:35 +02:00

40 lines
1.5 KiB
Python

# Copyright 2024 Camptocamp
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import api, models
from odoo.osv import expression
class LoyaltyRule(models.Model):
_inherit = "loyalty.rule"
@api.depends("product_ids", "product_category_id", "product_tag_id")
def _compute_valid_product_ids(self):
super()._compute_valid_product_ids()
excluded_products = self.env["product.product"].search_count(
[("loyalty_exclude", "=", True), ("available_in_pos", "=", True)]
)
# this check ensures that it only runs when there are loyalty-excluded products
if excluded_products:
for rule in self:
# exclude product when no config in loyalty rule
if not (
rule.product_ids
or rule.product_category_id
or rule.product_tag_id
or rule.product_domain not in ("[]", "[['sale_ok', '=', True]]")
):
rule.any_product = False
rule.valid_product_ids = self.env["product.product"].search(
[
("loyalty_exclude", "=", False),
("available_in_pos", "=", True),
],
order="id",
)
return True
def _get_valid_product_domain(self):
domain = super()._get_valid_product_domain()
domain = expression.AND([domain, [("loyalty_exclude", "=", False)]])
return domain