Files
odoo_source/addons/stock/views/product_strategy_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

113 lines
5.8 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="stock_putaway_list" model="ir.ui.view">
<field name="name">stock.putaway.rule.tree</field>
<field name="model">stock.putaway.rule</field>
<field name="arch" type="xml">
<tree string="Putaway Rules" editable="bottom" sample='1'>
<field name="company_id" invisible="1"/>
<field name="package_type_ids" invisible="1"/>
<field name="sequence" widget="handle"
invisible="context.get('invisible_handle', False)"/>
<field name="location_in_id" string="When product arrives in"
options="{'no_create': True}"
readonly="context.get('fixed_location', False)"/>
<field name="product_id" string="Product"
attrs="{'readonly': [('category_id', '!=', False)], 'required': [('category_id', '=', False), ('package_type_ids', '=', False)]}"
options="{'no_create': True, 'no_open': True}"
readonly="context.get('single_product', False)"
force_save="1"/>
<field name="category_id" string="Product Category"
attrs="{'readonly': [('product_id', '!=', False)], 'required': [('product_id', '=', False), ('package_type_ids', '=', False)]}"
options="{'no_create': True, 'no_open': True}"
readonly="context.get('fixed_category', False)"
force_save="1"/>
<field name="package_type_ids" string="Package type"
options="{'no_create': True, 'no_open': True}"
groups="stock.group_tracking_lot" widget="many2many_tags"
optional="show"/>
<field name="location_out_id"
attrs="{'readonly': [('location_in_id', '=', False)]}"
options="{'no_create': True}"
optional="show"/>
<field name="storage_category_id" string="Having Category"
groups="stock.group_stock_storage_categories"
options="{'no_create': True}"
optional="show"/>
<field name="company_id" groups="stock.group_stock_multi_locations" force_save="1" readonly="context.get('fixed_location', False)" options="{'no_create': True}" optional="show"/>
</tree>
</field>
</record>
<record id="view_removal" model="ir.ui.view">
<field name="name">product.removal.form</field>
<field name="model">product.removal</field>
<field name="arch" type="xml">
<form string="Removal">
<group col="4">
<field name="name"/>
<field name="method"/>
</group>
</form>
</field>
</record>
<record id="action_putaway_tree" model="ir.actions.act_window">
<field name="name">Putaways Rules</field>
<field name="res_model">stock.putaway.rule</field>
<field name="type">ir.actions.act_window</field>
<field name="view_mode">tree</field>
<field name="view_id" ref="stock_putaway_list"/>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
No putaway rule found. Let's create one!
</p><p>
Create new putaway rules to dispatch automatically specific products to their appropriate destination location upon receptions.
</p>
</field>
</record>
<record id="view_putaway_search" model="ir.ui.view">
<field name="name">stock.putaway.rule.search</field>
<field name="model">stock.putaway.rule</field>
<field name="arch" type="xml">
<search string="Putaway Rules">
<field name="product_id"/>
<field name="category_id"/>
<field name="location_in_id"/>
<field name="location_out_id"/>
<group expand='0' string='Filters'>
<filter name="filter_to_rules_on_product"
string="Rules on Products"
domain="[('product_id', '!=', False)]"/>
<filter name="filter_to_rules_on_category"
string="Rules on Categories"
domain="[('category_id' ,'!=', False)]"/>
</group>
<group expand="0" string="Group By">
<filter string="Location: When arrives to" name="location_in" context="{'group_by':'location_in_id'}"/>
<filter string="Location: Store to" name="location_out" context="{'group_by':'location_out_id'}"/>
</group>
</search>
</field>
</record>
<record model="ir.actions.act_window" id="category_open_putaway"> <!-- Putaway rules from category -->
<field name="name">Putaway Rules</field>
<field name="res_model">stock.putaway.rule</field>
<field name="context">{
'search_default_category_id': [active_id],
'fixed_category': True,
}</field>
</record>
<record model="ir.actions.act_window" id="location_open_putaway"> <!-- Putaway rules from location -->
<field name="name">Putaway Rules</field>
<field name="res_model">stock.putaway.rule</field>
<field name="context">{'fixed_location': True}</field>
<field name="domain">['|', ('location_out_id', '=', active_id), ('location_in_id', '=', active_id)]</field>
</record>
<menuitem id="menu_putaway" name="Putaway Rules" parent="stock.menu_warehouse_config"
action="action_putaway_tree" sequence="8" groups="stock.group_stock_multi_locations"/>
</odoo>