From 9900d297fcd183ae0ea35972be826ba22003cf8f Mon Sep 17 00:00:00 2001 From: Suherdy Yacob Date: Thu, 28 May 2026 12:14:32 +0700 Subject: [PATCH] fix: trigger client reload, specify view type, and update account company search criteria --- README.md | 13 +++++++++++++ models/loyalty_reward.py | 2 +- models/loyalty_voucher_generation_request.py | 1 + wizards/loyalty_generate_wizard.py | 1 + 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0dad962..1808f1c 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,19 @@ A custom Odoo 19 module introducing comprehensive security permissions, double-a --- +## 🩹 Recent Fixes & Compatibility Updates + +### 1. Odoo 19 Multi-Company Sharing Schema Compatibility +- Swapped deprecated `company_id` filters with the new standard Many2many `company_ids` domain mapping when querying `account.account` instances. This prevents `ValueError: Invalid field account.account.company_id` backend crashes when creating loyalty discount products. + +### 2. Client Action Preprocessing Safety +- Added explicit view layout parameters (`'views': [[False, 'form']]`) to the wizard action dictionaries. This prevents frontend JS crashes (`TypeError: Cannot read properties of undefined (reading 'map')`) when Odoo's web client pre-processes nested actions outside standard loaded actions. + +### 3. Real-Time State Synchronization +- Chained a soft-reload client action (`'next': {'type': 'ir.actions.client', 'tag': 'reload'}`) directly within the approval notification return payload. This ensures that the voucher request's state immediately updates to **Approved** in the UI and lists the newly generated voucher cards without requiring a manual page refresh. + +--- + ## 📂 Technical Layout & Structure ```text diff --git a/models/loyalty_reward.py b/models/loyalty_reward.py index 94c5bcd..9066219 100644 --- a/models/loyalty_reward.py +++ b/models/loyalty_reward.py @@ -26,7 +26,7 @@ class LoyaltyReward(models.Model): company = reward.company_id or self.env.company account = self.env['account.account'].sudo().search([ ('code', '=', '412201'), - ('company_id', '=', company.id) + ('company_ids', '=', company.id) ], limit=1) if account: vals['property_account_income_id'] = account.id diff --git a/models/loyalty_voucher_generation_request.py b/models/loyalty_voucher_generation_request.py index ecc474d..1ecd1c3 100644 --- a/models/loyalty_voucher_generation_request.py +++ b/models/loyalty_voucher_generation_request.py @@ -149,6 +149,7 @@ class LoyaltyVoucherGenerationRequest(models.Model): 'message': _('Vouchers generated successfully.'), 'type': 'success', 'sticky': False, + 'next': {'type': 'ir.actions.client', 'tag': 'reload'}, } } diff --git a/wizards/loyalty_generate_wizard.py b/wizards/loyalty_generate_wizard.py index 9461ffc..ef0bbba 100644 --- a/wizards/loyalty_generate_wizard.py +++ b/wizards/loyalty_generate_wizard.py @@ -40,6 +40,7 @@ class LoyaltyGenerateWizard(models.TransientModel): 'type': 'ir.actions.act_window', 'res_model': 'loyalty.voucher.generation.request', 'view_mode': 'form', + 'views': [[False, 'form']], 'res_id': requests[0].id, 'target': 'current', }