mirror of
https://github.com/bringout/oca-pos.git
synced 2026-04-23 03:01:59 +02:00
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>
40 lines
1.5 KiB
Python
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
|