access_restriction_by_user/views/stock_picking_views.xml

38 lines
2.3 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Inherit from the quality control view that adds the button -->
<!-- We need to ensure we target the right buttons. The Quality Checks button is added by quality_control/views/stock_picking_views.xml -->
<!-- The button names are 'check_quality', 'open_quality_alert_picking', 'action_open_quality_check_picking' -->
<record id="view_picking_form_inherit_access_restriction" model="ir.ui.view">
<field name="name">stock.picking.view.form.inherit.access.restriction</field>
<field name="model">stock.picking</field>
<field name="inherit_id" ref="quality_control.stock_picking_view_form_inherit_quality"/>
<field name="arch" type="xml">
<field name="state" position="before">
<field name="restrict_quality_check_button" invisible="1"/>
</field>
<!-- Hide the 'Quality Checks' button (header) -->
<xpath expr="//button[@name='check_quality']" position="attributes">
<attribute name="invisible">not quality_check_todo or state in ('done', 'cancel') or restrict_quality_check_button</attribute>
</xpath>
<!-- Hide the 'Quality Checks' smart buttons -->
<!-- There are multiple buttons with same name/icon but different states/colors -->
<!-- We target all of them if possible, or specifically by their index/attributes -->
<xpath expr="//button[@name='action_open_quality_check_picking'][1]" position="attributes">
<attribute name="invisible">not check_ids or quality_check_fail or not quality_check_todo or restrict_quality_check_button</attribute>
</xpath>
<xpath expr="//button[@name='action_open_quality_check_picking'][2]" position="attributes">
<attribute name="invisible">not check_ids or quality_check_fail or quality_check_todo or restrict_quality_check_button</attribute>
</xpath>
<xpath expr="//button[@name='action_open_quality_check_picking'][3]" position="attributes">
<attribute name="invisible">not check_ids or not quality_check_fail or restrict_quality_check_button</attribute>
</xpath>
</field>
</record>
</odoo>