Skip to content

Commit 3060426

Browse files
committed
[ADD] inventory: Improve stock info and UI in product form
Before: Users could easily get confused or make mistakes when managing stock, especially in multi-company environments. Important actions like updating quantity on hand were hard to find, and the interface didn’t clearly guide safe workflows. After: The interface now better supports new users by reducing confusion and make stock workflows safer. Risky actions are hidden if not appropriate, visual clarity helps users avoid errors and understand inventory status more easily. task-4965098
1 parent fbf9ee9 commit 3060426

File tree

5 files changed

+94
-0
lines changed

5 files changed

+94
-0
lines changed

quantity_on_hand/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Part of Odoo. See LICENSE file for full copyright and licensing details.
2+
from . import models

quantity_on_hand/__manifest__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
'name': 'Quantity on hand',
3+
'version': '1.0',
4+
'depends': ['stock'],
5+
'installable': True,
6+
'data': [
7+
'views/product_template_views.xml',
8+
],
9+
'license': 'LGPL-3',
10+
}

quantity_on_hand/models/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Part of Odoo. See LICENSE file for full copyright and licensing details.
2+
from . import product_template
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from odoo import api, fields, models
2+
3+
4+
class ProductTemplate(models.Model):
5+
_inherit = 'product.template'
6+
7+
is_multicompany = fields.Boolean(compute="_compute_is_multicompany")
8+
9+
@api.depends('company_id')
10+
def _compute_is_multicompany(self):
11+
for record in self:
12+
record.is_multicompany = len(self.env.user.company_ids) > 1
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<odoo>
3+
<record id="view_product_template_form_inherited" model="ir.ui.view">
4+
<field name="name">product.template.form.custom.inherit</field>
5+
<field name="model">product.template</field>
6+
<field name="inherit_id" ref="product.product_template_only_form_view" />
7+
<field name="arch" type="xml">
8+
9+
<xpath expr="//button[@name='action_update_quantity_on_hand']" position="attributes">
10+
<attribute name="invisible">1</attribute>
11+
</xpath>
12+
13+
<xpath expr="//button[@invisible='not show_on_hand_qty_status_button']" position="attributes">
14+
<attribute name="invisible">1</attribute>
15+
</xpath>
16+
17+
<xpath expr="//field[@name='virtual_available']" position='attributes'>
18+
<attribute name='decoration-danger'>virtual_available &lt; 0</attribute>
19+
<attribute name='decoration-primary'>virtual_available == 0</attribute>
20+
</xpath>
21+
22+
<xpath expr="//button[@name='action_product_tmpl_forecast_report']/div/span[hasclass('o_stat_value', 'd-flex', 'gap-1')]/field[@name='uom_name']" position='replace'>
23+
<span>Forecasted</span>
24+
</xpath>
25+
26+
<xpath expr="//button[@name='action_product_tmpl_forecast_report']/div/span[hasclass('o_stat_value', 'd-flex', 'gap-1')]" position='before'>
27+
<span class="o_stat_value d-flex gap-1">
28+
<field name="qty_available" nolabel="1" class="oe_inline" />
29+
<field name="uom_name" class="oe_inline" />
30+
</span>
31+
</xpath>
32+
33+
<xpath expr="//button[@name='action_product_tmpl_forecast_report']/div/span[hasclass('o_stat_text')]" position='attributes'>
34+
<attribute name='invisible'>1</attribute>
35+
</xpath>
36+
37+
</field>
38+
</record>
39+
40+
<record id="product_template_form_view_inherit" model="ir.ui.view">
41+
<field name="name">product.template.common.form.inherit</field>
42+
<field name="model">product.template</field>
43+
<field name="inherit_id" ref="product.product_template_form_view" />
44+
<field name="arch" type="xml">
45+
<xpath expr="//field[@name='product_tooltip']" position='attributes'>
46+
<attribute name='invisible'>type == 'consu'</attribute>
47+
</xpath>
48+
49+
<xpath expr="//field[@name='product_tooltip']" position="after">
50+
<label for="qty_available" invisible='not is_storable'>Quantity On Hand</label>
51+
<span class="d-flex gap-3">
52+
<field name="qty_available"
53+
readonly="is_multicompany"
54+
class="oe_inline"
55+
invisible='not is_storable'
56+
/>
57+
<field name="uom_name" class="oe_inline" invisible='not is_storable' />
58+
<button type="action"
59+
name="%(stock.action_product_stock_view)d"
60+
class="oe_stat_button oe_inline opacity-0 opacity-100-hover"
61+
invisible='not is_storable'>
62+
Update
63+
</button>
64+
</span>
65+
</xpath>
66+
</field>
67+
</record>
68+
</odoo>

0 commit comments

Comments
 (0)