summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnold Moyaux <arm@odoo.com>2020-03-18 09:48:02 +0000
committerArnold Moyaux <arm@odoo.com>2020-04-22 08:03:15 +0000
commitdb978e36092c5a3ea0cd4f868ed0a2a82462a4bf (patch)
treef8e77a2f0416cc107876da01025aee0e32576757
parent3f2815ab2f29dfcddbd616447e5f7a81c87b8f6a (diff)
[IMP] stock: product view usability
Route diagram directly open with a single warehouse and variant. Move fields and group to have a cleaner view. Task: 2161378
-rw-r--r--addons/stock/models/product.py17
-rw-r--r--addons/stock/views/product_views.xml27
2 files changed, 37 insertions, 7 deletions
diff --git a/addons/stock/models/product.py b/addons/stock/models/product.py
index 42f9aff225b..e80aa0e6aea 100644
--- a/addons/stock/models/product.py
+++ b/addons/stock/models/product.py
@@ -785,6 +785,23 @@ class ProductTemplate(models.Model):
})
return action
+ def action_open_routes_diagram(self):
+ products = False
+ if self.env.context.get('default_product_id'):
+ products = self.env['product.product'].browse(self.env.context['default_product_id'])
+ if not products and self.env.context.get('default_product_tmpl_id'):
+ products = self.env['product.template'].browse(self.env.context['default_product_tmpl_id']).product_variant_ids
+ if not self.user_has_groups('stock.group_stock_multi_warehouses') and len(products) == 1:
+ company = products.company_id or self.env.company
+ warehouse = self.env['stock.warehouse'].search([('company_id', '=', company.id)], limit=1)
+ return self.env.ref('stock.action_report_stock_rule').report_action(None, data={
+ 'product_id': products.id,
+ 'warehouse_ids': warehouse.ids,
+ })
+ action = self.env.ref('stock.action_stock_rules_report').read()[0]
+ action['context'] = self.env.context
+ return action
+
def action_product_tmpl_forecast_report(self):
action = self.env.ref('stock.report_stock_quantity_action_product').read()[0]
product_ids = self.with_context(active_test=False).product_variant_ids.filtered(lambda p: p.virtual_available != 0)
diff --git a/addons/stock/views/product_views.xml b/addons/stock/views/product_views.xml
index 97d9df3b7da..58d41d245a8 100644
--- a/addons/stock/views/product_views.xml
+++ b/addons/stock/views/product_views.xml
@@ -23,6 +23,15 @@
</field>
</record>
+ <record model="ir.actions.server" id="action_open_routes">
+ <field name="name">Routes</field>
+ <field name="model_id" ref="product.model_product_template"/>
+ <field name="state">code</field>
+ <field name="code">
+ action = model.action_open_routes_diagram()
+ </field>
+ </record>
+
<record id="view_stock_product_tree" model="ir.ui.view">
<field name="name">product.stock.tree.inherit</field>
<field name="model">product.product</field>
@@ -94,21 +103,25 @@
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_form_view"/>
<field name="arch" type="xml">
+ <xpath expr="//group[@name='group_lots_and_weight']" position="inside">
+ <label for="sale_delay" attrs="{'invisible': [('sale_ok', '=', False)]}"/>
+ <div attrs="{'invisible': [('sale_ok', '=', False)]}">
+ <field name="sale_delay" class="oe_inline" style="vertical-align:baseline"/> days
+ </div>
+ </xpath>
<xpath expr="//group[@name='group_lots_and_weight']" position="before">
<group string="Operations" name="operations">
<label for="route_ids" attrs="{'invisible': [('type', 'in', ['service', 'digital'])]}"/>
<div>
<field name="route_ids" class="mb-0" widget="many2many_checkboxes" attrs="{'invisible': [('type', 'in', ['service', 'digital'])]}"/>
- <button string="See routes diagram" type="action" name="%(action_stock_rules_report)d" icon="fa-cogs"
+ <button string="View Diagram" type="action" name="%(action_open_routes)d" icon="fa-arrow-right"
attrs="{'invisible':[('type', 'not in', ['product', 'consu'])]}"
class="btn btn-link pt-0" context="{'default_product_tmpl_id': id}"/>
</div>
<field name="route_from_categ_ids" widget="many2many_tags" readonly="1" attrs="{'invisible': [('route_from_categ_ids', '=', [])]}"/>
- <label for="sale_delay" attrs="{'invisible': [('sale_ok', '=', False)]}"/>
- <div attrs="{'invisible': [('sale_ok', '=', False)]}">
- <field name="sale_delay" class="oe_inline" style="vertical-align:baseline"/> days
- </div>
</group>
+ </xpath>
+ <xpath expr="//group[@name='group_lots_and_weight']" position="after">
<group string="Traceability" name="traceability" groups="stock.group_production_lot"
attrs="{'invisible': [('type', '=', 'consu')]}">
<field name="tracking" widget="radio" attrs="{'invisible': [('type', 'in', ['service', 'digital'])]}"/>
@@ -270,7 +283,7 @@
attrs="{'invisible': [('type', '=', 'service')]}"
context="{'invisible_handle': True, 'single_product': True}"/>
</div>
- <xpath expr="//button[@name='%(action_stock_rules_report)d']" position="attributes">
+ <xpath expr="//button[@name='%(action_open_routes)d']" position="attributes">
<attribute name="context">
{'default_product_id': id}
</attribute>
@@ -369,7 +382,7 @@
<attribute name="attrs">{'invisible': [('type', 'not in', ['product', 'consu'])]}</attribute>
</xpath>
- <xpath expr="//group[@name='group_lots_and_weight']" position="inside">
+ <xpath expr="//label[@for='weight']" position="before">
<field name="responsible_id" domain="[('share', '=', False)]"/>
</xpath>
</data>