[FIX] purchase: PO stat button no groups

To reproduce the issue:
1. Create user with no access rights apart from user rights in Sales,
   Sign, Project and Timesheet
2. Create a project, add a task inside and link an analytic account
   to the project
3. Create an RFQ, add a product linked to the analytic account
4. Confirm order, receive product, validate, create bill
5. Log in with user
6. Try to access the analytic account through:
   Project->Task->project name->Settings->Analytic account
7. An error message pops-up "You are not allowed to access Purchase
   Order (purchase.order) records."

Error: You should be able to access the analytic account, but the
Purchase Order smart button should not be visible/present

The data access by the smart button was not stopped by rules or
groups, thus data was always trying to be loaded, even when the user
did not have the access rights

OPW-3180788

closes odoo/odoo#115058

X-original-commit: 9e8b2ba1ae05de72f492d833edd8da91ded6f5b0
Signed-off-by: Adrien Widart <awt@odoo.com>
Signed-off-by: Demany Antoine (ande) <ande@odoo.com>
This commit is contained in:
Antoine (ande)
2023-03-14 12:24:03 +01:00
parent 4df87cf10f
commit 8d40bcf89a
@@ -8,7 +8,8 @@
<field name="arch" type="xml">
<div name="button_box" position="inside">
<button class="oe_stat_button" type="object" name="action_view_purchase_orders"
icon="fa-credit-card" attrs="{'invisible': [('purchase_order_count', '=', 0)]}">
icon="fa-credit-card" attrs="{'invisible': [('purchase_order_count', '=', 0)]}"
groups="purchase.group_purchase_user">
<field string="Purchase Orders" name="purchase_order_count" widget="statinfo"/>
</button>
</div>