From 3a156a188e9a95e4297491f18858880ba5a66c2f Mon Sep 17 00:00:00 2001 From: Suherdy Yacob Date: Mon, 1 Jun 2026 23:08:33 +0700 Subject: [PATCH] fix: explicitly search for Membership Silver program and clean up README formatting --- README.md | 29 +++++++++-------------------- models/res_partner.py | 9 +++++++-- 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 8a73f96..f2921b4 100644 --- a/README.md +++ b/README.md @@ -4,29 +4,18 @@ This custom Odoo module enhances the POS Loyalty interface and partner creation ## Features -1. **Strict Customer Selection Filter:** - - Limits customer loading and search lists in the POS UI strictly to real individuals who hold an active membership or loyalty card (`is_loyalty_member = True`). - - Automatically excludes cashier accounts, user accounts, and company partners from being selected as customers. +* **Strict Customer Selection Filter:** Limits customer loading and search lists in the POS UI strictly to real individuals who hold an active membership or loyalty card (`is_loyalty_member = True`). Automatically excludes cashier accounts, user accounts, and company partners from being selected as customers. -2. **Simplified Customer Creation Wizard:** - - Overrides the POS Customer Edit/Creation screen to show only essential details: - * Name - * Phone - * Email - * Address (Street, Zip, City, State, Country) - * Birthday +* **Simplified Customer Creation Wizard:** Overrides the POS Customer Edit/Creation screen to show only essential details: Name, Phone, Email, Address (Street, Zip, City, State, Country), and Birthday. -3. **Automatic Lowest Level Membership Assignment:** - - Automatically provisions new partners with a loyalty card for the lowest membership tier (`Membership Silver`) immediately upon registration. +* **Automatic Lowest Level Membership Assignment:** Automatically provisions new partners with a loyalty card for the lowest membership tier (`Membership Silver`) immediately upon registration. -4. **Robust Multi-Company Loyalty Processing:** - - Solves a core Odoo 19 multi-company operational bug where cashiers in branch companies encounter "Access Errors" when validating orders for customers whose loyalty cards belong to the parent company. - - Bypasses company-specific record rules during POS loyalty audit logging using standard and safe `sudo` environment execution. +* **Robust Multi-Company Loyalty Processing:** Solves a core Odoo 19 multi-company operational bug where cashiers in branch companies encounter "Access Errors" when validating orders for customers whose loyalty cards belong to the parent company. Bypasses company-specific record rules during POS loyalty audit logging using standard and safe `sudo` environment execution. -5. **Loyalty Reward and Point Access Control:** - - Restricts loyalty program reward eligibility, point balance displays, and program applicability in the POS UI strictly to customers who have a persisted, active card in the database for that specific program. - - Prevents unauthorized claim/access to zero-point rewards (e.g., 100% discount rewards in executive/exclusive programs) by non-enrolled members. +* **Loyalty Reward and Point Access Control:** Restricts loyalty program reward eligibility, point balance displays, and program applicability in the POS UI strictly to customers who have a persisted, active card in the database for that specific program. Prevents unauthorized claim/access to zero-point rewards (e.g., 100% discount rewards in executive/exclusive programs) by non-enrolled members. ## Technical Details -- **JS OWL Patching:** Overrides POS frontend partner management and order processing (`PosOrder`) safely using clean, standard owl-level class overrides to filter program eligibility, claimable rewards, and loyalty point lists based on card status. -- **Python Inheritance:** Customizes backend models (`res.partner`, `pos.order`) to clean loading domains and securely provision cross-company data. + +* **JS OWL Patching:** Overrides POS frontend partner management and order processing (`PosOrder`) safely using clean, standard owl-level class overrides to filter program eligibility, claimable rewards, and loyalty point lists based on card status. + +* **Python Inheritance:** Customizes backend models (`res.partner`, `pos.order`) to clean loading domains and securely provision cross-company data. diff --git a/models/res_partner.py b/models/res_partner.py index e5ec1d9..a1dbc1d 100644 --- a/models/res_partner.py +++ b/models/res_partner.py @@ -63,10 +63,15 @@ class ResPartner(models.Model): # Find the lowest membership program level (Membership Silver) lowest_program = self.env['loyalty.program'].sudo().search( - [('multi_level_membership', '=', True)], - order='minimum_spend asc', + [('multi_level_membership', '=', True), ('name', '=ilike', 'Membership Silver')], limit=1 ) + if not lowest_program: + lowest_program = self.env['loyalty.program'].sudo().search( + [('multi_level_membership', '=', True)], + order='minimum_spend asc', + limit=1 + ) if lowest_program: existing_card = self.env['loyalty.card'].sudo().search([ ('partner_id', '=', partner.id),