Files
odoo_source/addons/mrp_subcontracting/views/stock_move_views.xml
T
Denis Ledoux 0501bbd62e [IMP] base: uniform "groups" in back-end view
This revision is to make uniform the behavior of the `groups` attribute
on the Python model fields
and on the node in the view architecture.
In both cases, remove the node from the view completely.

Before this revision,

in a back-end view:
 - In the Python model, if a field has the `groups` attribute set
   and the user is not part of
   the groups, the field is removed, completely, from the view.
 - In the view architecture, if a node has the `groups` attribute set
   and the user is not part of
   the groups, the node is made invisible (not completely removed, just
   made invisible).

in a front-end view:
 - if a node has a "groups" or "t-groups" set and the user
   is not part of the groups, the node is removed from the view.

So it's 2/3 cases removing nodes restricted to a group.
and 1/3 case making invisible nodes restricted to a group.
It's simpler to have a uniform behavior for the 3 cases,
simpler to understandard for developers.

In addition, this will help for the goal to cache back-end views.
It makes possible to convert views using the `groups_id` field
by moving the content of these views directly
in the view to which they add content which is suppose to be completely
removed when the user has not the according group.
By getting rid of the `groups_id` many2many field on `ir.ui.view`,
it makes possible to cache the view architecture without
requiring to use the groups in the cache key.
Currently, if we want to cache the view architecture,
it would be required to use the intersection of the user
groups with the `groups_id` groups of the view,
making it costly to compute the cache key,
therefore altering the performance point to cache the view
architectures.

closes odoo/odoo#95729

Related: odoo/enterprise#29592
Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
2022-08-19 19:10:39 +02:00

192 lines
11 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="mrp_subcontracting_stock_move_line_tree_view" model="ir.ui.view">
<field name="name">mrp.subcontracting.stock.move.line.tree.view</field>
<field name="model">stock.move.line</field>
<field name="priority">1000</field>
<field name="arch" type="xml">
<tree editable="bottom">
<field name="company_id" invisible="1"/>
<field name="product_uom_category_id" invisible="1"/>
<field name="owner_id" invisible="1"/>
<field name="tracking" invisible="1"/>
<field name="package_id" invisible="1"/>
<field name="result_package_id" invisible="1"/>
<field name="location_id" invisible="1"/>
<field name="location_dest_id" invisible="1"/>
<field name="state" invisible="1"/>
<!-- Don't put move_id here to avoid that the framework send falsy move_id -->
<field name="id" invisible="1"/>
<field name="product_id" required="1" domain="[('id', 'in', context.get('bom_product_ids'))] if context.get('is_subcontracting_portal') else []"/>
<field name="lot_id"
attrs="{'invisible': [('tracking', 'not in', ('serial', 'lot'))], 'required': [('tracking', 'in', ('serial', 'lot'))]}"
context="{'default_product_id': product_id, 'default_company_id': company_id}"/>
<field name="reserved_uom_qty" readonly="1" force_save="1"/>
<field name="qty_done"
decoration-warning="reserved_uom_qty &lt; qty_done"
decoration-success="reserved_uom_qty == qty_done"/>
<field name="product_uom_id" groups="uom.group_uom"/>
</tree>
</field>
</record>
<record id="mrp_subcontracting_portal_stock_move_line_tree_view" model="ir.ui.view">
<field name="name">mrp.subcontracting.portal.stock.move.line.tree.view</field>
<field name="model">stock.move.line</field>
<field name="mode">primary</field>
<field name="priority">1000</field>
<field name="inherit_id" ref="mrp_subcontracting_stock_move_line_tree_view" />
<field name="arch" type="xml">
<xpath expr="//field[@name='lot_id']" position="attributes">
<attribute name="options">{'no_create_edit': True, 'no_open': True}</attribute>
</xpath>
<xpath expr="//field[@name='product_id']" position="attributes">
<attribute name="options">{'no_open': True}</attribute>
</xpath>
</field>
</record>
<record id="mrp_subcontracting_view_stock_move_line_operation_tree" model="ir.ui.view">
<field name="name">mrp.subcontracting.stock.move.line.operations.tree</field>
<field name="model">stock.move.line</field>
<field name="mode">primary</field>
<field name="priority">1000</field>
<field name="inherit_id" ref="stock.view_stock_move_line_operation_tree" />
<field name="arch" type="xml">
<xpath expr="//field[@name='lot_id']" position="attributes">
<attribute name="options">{'no_create_edit': True, 'no_open': True}</attribute>
</xpath>
</field>
</record>
<record id="mrp_subcontracting_view_stock_move_operations" model="ir.ui.view">
<field name="name">mrp.subcontracting.stock.move.operations.form</field>
<field name="model">stock.move</field>
<field name="mode">primary</field>
<field name="priority">1000</field>
<field name="inherit_id" ref="stock.view_stock_move_operations" />
<field name="arch" type="xml">
<xpath expr="//field[@name='move_line_ids']" position="attributes">
<attribute name="context">{'tree_view_ref': 'mrp_subcontracting.mrp_subcontracting_view_stock_move_line_operation_tree', 'default_product_uom_id': product_uom, 'default_picking_id': picking_id, 'default_move_id': id, 'default_product_id': product_id, 'default_location_id': location_id, 'default_location_dest_id': location_dest_id, 'default_company_id': company_id}</attribute>
</xpath>
</field>
</record>
<record id="mrp_subcontracting_view_stock_move_nosuggest_operations" model="ir.ui.view">
<field name="name">mrp.subcontracting.stock.move.operations.nosuggest.form</field>
<field name="model">stock.move</field>
<field name="mode">primary</field>
<field name="priority">1000</field>
<field name="inherit_id" ref="stock.view_stock_move_nosuggest_operations" />
<field name="arch" type="xml">
<xpath expr="//field[@name='move_line_nosuggest_ids']" position="attributes">
<attribute name="context">{'tree_view_ref': 'mrp_subcontracting.mrp_subcontracting_view_stock_move_line_operation_tree','default_picking_id': picking_id, 'default_move_id': id, 'default_product_id': product_id, 'default_location_id': location_id, 'default_location_dest_id': location_dest_id, 'default_company_id': company_id}</attribute>
</xpath>
</field>
</record>
<record id="mrp_subcontracting_move_form_view" model="ir.ui.view">
<field name="name">mrp.subcontracting.move.form.view</field>
<field name="model">stock.move</field>
<field name="priority">1000</field>
<field name="arch" type="xml">
<form create="0" delete="0">
<header>
<field name="state" widget="statusbar"/>
</header>
<sheet>
<field name="product_uom_category_id" invisible="1"/>
<field name="company_id" invisible="1"/>
<field name="product_id" invisible="1"/>
<field name="sequence" invisible="1"/>
<field name="location_id" invisible="1"/>
<field name="picking_id" invisible="1"/>
<field name="location_dest_id" invisible="1"/>
<field name="has_tracking" invisible="1"/>
<field name="product_uom" invisible="1"/>
<field name="product_uom_qty" invisible="1"/>
<group>
<field name="order_finished_lot_id"/>
<field name="product_uom" groups="uom.group_uom"/>
<field name="quantity_done" string="Total Consumed" readonly="1"/>
</group>
<field name="move_line_ids"
attrs="{'readonly': [('state', 'in', ['done', 'cancel'])]}"
context="{'default_product_uom_id': product_uom, 'default_picking_id': picking_id, 'default_move_id': id, 'default_product_id': product_id, 'default_location_id': location_id, 'default_location_dest_id': location_dest_id, 'default_company_id': company_id}">
<tree editable="bottom" decoration-muted="state in ('done', 'cancel')">
<field name="company_id" invisible="1"/>
<field name="state" invisible="1"/>
<field name="tracking" invisible="1"/>
<field name="product_uom_id" invisible="1"/>
<field name="product_uom_category_id" invisible="1"/>
<field name="picking_id" invisible="1"/>
<field name="move_id" invisible="1"/>
<field name="location_id" invisible="1"/>
<field name="location_dest_id" invisible="1"/>
<field name="product_id" readonly="1" force_save="1"/>
<field name="qty_done"/>
<field name="lot_id" attrs="{'column_invisible':[('parent.has_tracking', 'not in', ('serial', 'lot'))], 'required': [('tracking', 'in', ('serial', 'lot'))]}" context="{'default_product_id': product_id, 'default_company_id': company_id}"/>
</tree>
</field>
</sheet>
</form>
</field>
</record>
<record id="mrp_subcontracting_portal_move_form_view" model="ir.ui.view">
<field name="name">mrp.subcontracting.portal.move.form.view</field>
<field name="model">stock.move</field>
<field name="mode">primary</field>
<field name="priority">1000</field>
<field name="inherit_id" ref="mrp_subcontracting_move_form_view" />
<field name="arch" type="xml">
<xpath expr="//field[@name='order_finished_lot_id']" position="attributes">
<attribute name="options">{'no_open': True}</attribute>
</xpath>
<xpath expr="//tree" position="attributes">
<attribute name="no_open">1</attribute>
</xpath>
<xpath expr="//tree/field[@name='lot_id']" position="attributes">
<attribute name="options">{'no_create_edit': True, 'no_open': True}</attribute>
</xpath>
</field>
</record>
<record id="mrp_subcontracting_move_tree_view" model="ir.ui.view">
<field name="name">mrp.subcontracting.move.tree.view</field>
<field name="model">stock.move</field>
<field name="priority">1000</field>
<field name="arch" type="xml">
<tree delete="0" create="0" decoration-muted="is_done" decoration-warning="quantity_done - product_uom_qty &gt; 0.0001" decoration-success="not is_done and quantity_done - product_uom_qty &lt; 0.0001" js_class="subcontracting_portal_move_list_view">
<field name="company_id" invisible="1"/>
<field name="sequence" invisible="1"/>
<field name="product_uom_category_id" invisible="1"/>
<field name="name" invisible="1"/>
<field name="unit_factor" invisible="1"/>
<field name="date" invisible="1"/>
<field name="picking_type_id" invisible="1"/>
<field name="has_tracking" invisible="1"/>
<field name="operation_id" invisible="1"/>
<field name="is_done" invisible="1"/>
<field name="bom_line_id" invisible="1"/>
<field name="location_id" invisible="1"/>
<field name="warehouse_id" invisible="1"/>
<field name="product_uom_qty" invisible="1"/>
<field name="location_dest_id" invisible="1"/>
<field name="state" invisible="1" force_save="1"/>
<field name="raw_material_production_id" invisible="1"/>
<field name="product_id" required="1"/>
<field name="order_finished_lot_id"/>
<field name="reserved_availability" attrs="{'invisible': [('is_done', '=', True)]}" string="Reserved"/>
<field name="quantity_done" string="Consumed" readonly="1"/>
<field name="product_uom" groups="uom.group_uom"/>
</tree>
</field>
</record>
<record id="view_move_search" model="ir.ui.view">
<field name="name">stock.move.search</field>
<field name="model">stock.move</field>
<field name="inherit_id" ref="stock.view_move_search" />
<field name="arch" type="xml">
<xpath expr="//field[@name='partner_id']" position="after">
<field name="order_finished_lot_id"/>
</xpath>
</field>
</record>
</odoo>