[FIX] sale_loyalty: allow invoicing-only users to open sale orders
Steps to reproduce:
1. Create a user in the Invoicing group (account.group_account_invoice)
only, without any Sales group.
2. As that user, open any sale order form (draft or confirmed with
loyalty history).
Issue:
The form never opens; the client raises "You are not allowed to
access 'Loyalty Coupon' (loyalty.card) records". This blocks a user
who already has read/write access to sale.order in core, via the
access_sale_order_invoicing_payments rule in sale's own security
CSV, from doing their job.
Cause:
Two non-sudo reads in the sale.order extension hit loyalty models
that are restricted to the Sales groups: the gift card stat button
count queries loyalty.card directly, and the loyalty summary looks
up the coupon point name via coupon_point_ids.coupon_id without the
sudo already used one line above for loyalty.history.
Fix:
Gate the gift card count query behind a has_access('read') check, so
a user without access simply sees a zero count (the stat button
stays hidden), matching the has_access guard sale.order already uses
in _create_invoices(). Read the coupon point name through sudo(),
consistent with the loyalty.history read beside it, since the
loyalty summary is meant to be visible to anyone who can already
read the order.
Signed-off-by: David Tran <david.tran@tvtmarine.com>
(cherry picked from commit d5acfaf89b7beffa9ff6c3289432ee0507e55683)
| Subbuilds | Name | State | Detail |
|---|---|---|---|
| Build 418400 | At install tests: from account to website_timesheet 79m | Killed | Log |
| Build 418401 | Post install tests: step install all modules 15m | Killed | Log |
| Build 418402 | Post install tests: from account to hr_recruitment_survey | Killed | Log |
| Build 418403 | Post install tests: from hr_skills to phone_validation | Killed | Log |
| Build 418404 | Post install tests: from point_of_sale to purchase_requisition_stock | Killed | Log |
| Build 418405 | Post install tests: from purchase_stock to test_inherits_depends | Killed | Log |
| Build 418406 | Post install tests: from test_mail to to_product_return_reason_stock | Killed | Log |
| Build 418407 | Post install tests: from to_sale_order_advance to viin_approval_purpose_routing 28m | Killed | Log |
| Build 418408 | Post install tests: from viin_approval_sale to viin_product 44m | Killed | Log |
| Build 418409 | Post install tests: from viin_project to web_unsplash | Killed | Log |
| Build 418410 | Post install tests: from website to website_timesheet | Killed | Log |
| Create Date | Level | Message |
|---|---|---|
| 09/24/2026 20:40:15 | INFO |
Updated repository Viindoo-tvtmaaddons
|
| 09/24/2026 20:40:15 | INFO |
Updated repository Viindoo-erponline-enterprise
|
| 09/24/2026 20:40:15 | INFO |
Updated repository Viindoo-branding
|
| 09/24/2026 20:40:15 | INFO |
Cloned repository Viindoo-odoo
|