fix: trigger client reload, specify view type, and update account company search criteria

This commit is contained in:
Suherdy Yacob 2026-05-28 12:14:32 +07:00
parent 98486e284e
commit 9900d297fc
4 changed files with 16 additions and 1 deletions

View File

@ -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 ## 📂 Technical Layout & Structure
```text ```text

View File

@ -26,7 +26,7 @@ class LoyaltyReward(models.Model):
company = reward.company_id or self.env.company company = reward.company_id or self.env.company
account = self.env['account.account'].sudo().search([ account = self.env['account.account'].sudo().search([
('code', '=', '412201'), ('code', '=', '412201'),
('company_id', '=', company.id) ('company_ids', '=', company.id)
], limit=1) ], limit=1)
if account: if account:
vals['property_account_income_id'] = account.id vals['property_account_income_id'] = account.id

View File

@ -149,6 +149,7 @@ class LoyaltyVoucherGenerationRequest(models.Model):
'message': _('Vouchers generated successfully.'), 'message': _('Vouchers generated successfully.'),
'type': 'success', 'type': 'success',
'sticky': False, 'sticky': False,
'next': {'type': 'ir.actions.client', 'tag': 'reload'},
} }
} }

View File

@ -40,6 +40,7 @@ class LoyaltyGenerateWizard(models.TransientModel):
'type': 'ir.actions.act_window', 'type': 'ir.actions.act_window',
'res_model': 'loyalty.voucher.generation.request', 'res_model': 'loyalty.voucher.generation.request',
'view_mode': 'form', 'view_mode': 'form',
'views': [[False, 'form']],
'res_id': requests[0].id, 'res_id': requests[0].id,
'target': 'current', 'target': 'current',
} }