Files
odoo_source/addons/stock/views/stock_location_views.xml
T
FrancoisGe c998fdd77b [FIX] base: consider multi_edit="1" views editable
Since odoo/odoo#95729

nodes with a `groups=` are completely removed from the views when
the user is not part of the group, instead of being made invisible.

In that PR, views have been adapted to add back fields, with invisible="1",
when they were required, for instance when they were used in a domain
of another field which was still there despite the user is not part
of the given group.

As `tree` views having `multi_edit="1"` where not considered
as editable views, the domain of fields in these views were not
validated:
- https://github.com/odoo/odoo/blob/1fb8fa16ab7dc298d54f089d7163fb556dbc5fcc/odoo/addons/base/models/ir_ui_view.py#L1460
- https://github.com/odoo/odoo/blob/1fb8fa16ab7dc298d54f089d7163fb556dbc5fcc/odoo/addons/base/models/ir_ui_view.py#L1321-L1322

while they are well required for the web client,
in `multi_edit="1"` this is possible to edit relational/many2one field,
and therefore it will do `name_search` calls using the domain of the
field, and therefore the fields used in these domains must always
be present in the views. Without it, a crash in the web client occurs
when attempting to edit the relational/many2one field.

This revision targets to consider the `multi_edit="1"` tree views
as editable, to make the field domains validated as they should be.

Hence, views are adapted to add back fields with `invisible="1"`
when they are required in domains of other fields.

Part-of: odoo/odoo#103790
2022-10-23 12:30:03 +02:00

262 lines
14 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="act_product_location_open" model="ir.actions.act_window">
<field name="name">Products</field>
<field name="res_model">product.product</field>
<field name="context">{'location': active_id, 'search_default_real_stock_available': 1, 'search_default_virtual_stock_available': 1,
'search_default_virtual_stock_negative': 1, 'search_default_real_stock_negative': 1, 'create': False}</field>
<field name="binding_model_id" ref="model_stock_location"/>
<field name="binding_view_types">form</field>
<field name="search_view_id" ref="stock.stock_product_search_form_view"/>
</record>
<record id="view_location_form" model="ir.ui.view">
<field name="name">stock.location.form</field>
<field name="model">stock.location</field>
<field name="arch" type="xml">
<form string="Stock Location">
<field name="company_id" invisible="1"/>
<sheet>
<div class="oe_button_box" name="button_box">
<button string="Putaway Rules"
class="oe_stat_button"
icon="fa-random" name="%(location_open_putaway)d" type="action"
groups="stock.group_stock_multi_locations" context="{'default_company_id': company_id}"/>
<button string="Current Stock"
class="oe_stat_button"
icon="fa-cubes" name="%(location_open_quants)d" type="action"/>
</div>
<widget name="web_ribbon" title="Archived" bg_color="bg-danger" attrs="{'invisible': [('active', '=', True)]}"/>
<label for="name"/>
<h1><field name="name" placeholder="e.g. Spare Stock"/></h1>
<label for="location_id"/>
<h2><field name="location_id" placeholder="e.g. Physical Locations" options="{'no_create': True}"/></h2>
<group>
<group string="Additional Information" name="additional_info">
<field name="active" invisible="1"/>
<field name="usage"/>
<field name="storage_category_id" attrs="{'invisible': [('usage', '!=', 'internal')]}" groups="stock.group_stock_storage_categories"/>
<field name="company_id" groups="base.group_multi_company" options="{'no_create': True}"/>
<field name="scrap_location" attrs="{'invisible': [('usage', 'not in', ('inventory', 'internal'))]}"/>
<field name="return_location"/>
<field name="replenish_location" attrs="{'invisible': [('usage', '!=', 'internal')]}"/>
</group>
<group string="Cyclic Counting" attrs="{'invisible': ['|', ('usage', 'not in', ('internal', 'transit')), ('company_id', '=', False)]}">
<field name="cyclic_inventory_frequency"/>
<field name="last_inventory_date"/>
<field name="next_inventory_date" attrs="{'invisible': [('active', '=', False)]}"/>
</group>
<group string="Logistics" groups="stock.group_adv_location">
<field name="removal_strategy_id" options="{'no_create': True}"/>
</group>
</group>
<field name="comment" placeholder="External note..."/>
</sheet>
</form>
</field>
</record>
<record id="stock_location_view_form_editable" model="ir.ui.view">
<field name="name">stock.location.form.editable</field>
<field name="model">stock.location</field>
<field name="inherit_id" ref="stock.view_location_form"/>
<field name="arch" type="xml">
<xpath expr="//form" position="attributes">
<attribute name="create">false</attribute>
</xpath>
</field>
</record>
<record id="view_location_search" model="ir.ui.view">
<field name="name">stock.location.search</field>
<field name="model">stock.location</field>
<field name="arch" type="xml">
<search string="Stock Locations">
<field name="complete_name" string="Stock Locations"/>
<filter name="in_location" string="Internal" domain="[('usage', '=', 'internal')]" help="Internal Locations"/>
<filter name="customer" string="Customer" domain="[('usage', '=', 'customer')]" help="Customer Locations"/>
<filter name="prod_inv_location" string="Production" domain="[('usage', 'in', ['inventory', 'production'])]" help="Production Locations"/>
<filter name="supplier" string="Vendor" domain="[('usage', '=', 'supplier')]" help="Vendor Locations"/>
<field name="location_id" string="Parent Location"/>
<separator/>
<filter string="Archived" name="inactive" domain="[('active','=',False)]"/>
</search>
</field>
</record>
<record id="view_location_tree2" model="ir.ui.view">
<field name="name">stock.location.tree</field>
<field name="model">stock.location</field>
<field name="priority" eval="2"/>
<field name="arch" type="xml">
<tree string="Stock Location" decoration-info="usage=='view'" decoration-danger="usage=='internal'" multi_edit="1">
<field name="company_id" invisible="1"/>
<field name="active" invisible="1"/>
<field name="complete_name" string="Location"/>
<field name="usage"/>
<field name="storage_category_id" attrs="{'readonly': [('usage', '!=', 'internal')]}" groups="stock.group_stock_storage_categories"/>
<field name="company_id" groups="base.group_multi_company"/>
</tree>
</field>
</record>
<record id="stock_location_view_tree2_editable" model="ir.ui.view">
<field name="name">stock.location.tree2.editable</field>
<field name="model">stock.location</field>
<field name="inherit_id" ref="stock.view_location_tree2"/>
<field name="arch" type="xml">
<xpath expr="//tree" position="attributes">
<attribute name="create">false</attribute>
</xpath>
</field>
</record>
<record model="ir.actions.act_window" id="action_storage_category_locations">
<field name="name">Locations</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">stock.location</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('storage_category_id', '=', active_id)]</field>
</record>
<record id="action_location_form" model="ir.actions.act_window">
<field name="name">Locations</field>
<field name="res_model">stock.location</field>
<field name="type">ir.actions.act_window</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_location_tree2"/>
<field name="search_view_id" ref="view_location_search"/>
<field name="context">{'search_default_in_location':1}</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Add a new location
</p><p>
Define your locations to reflect your warehouse structure and
organization. Odoo is able to manage physical locations
(warehouses, shelves, bin, etc), partner locations (customers,
vendors) and virtual locations which are the counterpart of
the stock operations like the manufacturing orders
consumptions, inventories, etc.
</p><p>
Every stock operation in Odoo moves the products from one
location to another one. For instance, if you receive products
from a vendor, Odoo will move products from the Vendor
location to the Stock location. Each report can be performed on
physical, partner or virtual locations.
</p>
</field>
</record>
<record id="action_prod_inv_location_form" model="ir.actions.act_window">
<field name="name">Locations</field>
<field name="res_model">stock.location</field>
<field name="type">ir.actions.act_window</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_location_tree2"/>
<field name="search_view_id" ref="view_location_search"/>
<field name="context">{'search_default_prod_inv_location': 1}</field>
</record>
<menuitem action="action_location_form" id="menu_action_location_form"
parent="menu_warehouse_config" sequence="2" groups="stock.group_stock_multi_locations"/>
<!--Routes-->
<record id="stock_location_route_tree" model="ir.ui.view">
<field name="name">stock.location.route.tree</field>
<field name="model">stock.route</field>
<field name="arch" type="xml">
<tree string="Routes">
<field name="sequence" widget="handle" />
<field name="name"/>
<field name="active" invisible="1"/>
<field name="company_id" groups="base.group_multi_company"/>
</tree>
</field>
</record>
<record id="stock_location_route_form_view" model="ir.ui.view">
<field name="name">stock.location.route.form</field>
<field name="model">stock.route</field>
<field eval="7" name="priority" />
<field name="arch" type="xml">
<form string="Route">
<field name="company_id" invisible="1"/>
<sheet>
<widget name="web_ribbon" title="Archived" bg_color="bg-danger" attrs="{'invisible': [('active', '=', True)]}"/>
<div class="oe_title">
<label for="name"/>
<h1><field name="name" placeholder="e.g. Two-steps reception"/></h1>
</div>
<group>
<group>
<field name="sequence" string="Sequence" groups="base.group_no_one"/>
<field name="supplied_wh_id" groups="base.group_no_one"/>
<field name="active" invisible="1"/>
<field name="company_id" groups="base.group_multi_company" options="{'no_create': True}"/>
</group>
</group>
<group string="Applicable On" name="route_selector">
<p colspan="2" class="oe_grey">Select the places where this route can be selected</p>
<group>
<field name="product_categ_selectable" string="Product Categories"/>
<field name="product_selectable" string="Products"/>
<field name="packaging_selectable" string="Packagings" groups="product.group_stock_packaging"/>
</group>
<group>
<label for="warehouse_selectable" string="Warehouses"/>
<div class="o_row">
<field name="warehouse_selectable" class="oe_inline" nolabel="1"/>
<field name="warehouse_domain_ids" invisible="1"/>
<field name="warehouse_ids" widget="many2many_tags" nolabel="1"
attrs="{'invisible': [('warehouse_selectable', '=', False)]}"/>
</div>
</group>
</group>
<group string="Rules" >
<field name="rule_ids" colspan="2" nolabel="1" context="{'default_company_id': company_id, 'form_view_ref':'stock.view_route_rule_form'}">
<tree>
<field name="sequence" widget="handle"/>
<field name="action"/>
<field name="location_src_id" options="{'no_create': True}"/>
<field name="location_dest_id" options="{'no_create': True}"/>
</tree>
</field>
</group>
</sheet>
</form>
</field>
</record>
<record id="stock_location_route_view_search" model="ir.ui.view">
<field name="name">stock.location.route.search</field>
<field name="model">stock.route</field>
<field name="arch" type="xml">
<search string="Route">
<field name="name"/>
<filter string="Archived" name="inactive" domain="[('active','=',False)]"/>
</search>
</field>
</record>
<record id="action_routes_form" model="ir.actions.act_window">
<field name="name">Routes</field>
<field name="res_model">stock.route</field>
<field name="type">ir.actions.act_window</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="stock_location_route_tree" />
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Add a new route
</p><p>
You can define here the main routes that run through
your warehouses and that define the flows of your products. These
routes can be assigned to a product, a product category or be fixed
on procurement or sales order.
</p>
</field>
</record>
<menuitem id="menu_routes_config" action="action_routes_form" name="Routes" parent="menu_warehouse_config" sequence="3" groups="stock.group_adv_location"/>
</odoo>