From d3164e9c06376cb5b02cdec8c75d51d54a3fcb68 Mon Sep 17 00:00:00 2001 From: arkp-odoo Date: Wed, 23 Jul 2025 17:58:04 +0530 Subject: [PATCH] [ADD] inventory: Improve stock info and UI in product form MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- quantity_on_hand/__init__.py | 3 + quantity_on_hand/__manifest__.py | 13 ++++ quantity_on_hand/models/__init__.py | 3 + quantity_on_hand/models/product_template.py | 21 +++++ .../views/product_template_views.xml | 78 +++++++++++++++++++ 5 files changed, 118 insertions(+) create mode 100644 quantity_on_hand/__init__.py create mode 100644 quantity_on_hand/__manifest__.py create mode 100644 quantity_on_hand/models/__init__.py create mode 100644 quantity_on_hand/models/product_template.py create mode 100644 quantity_on_hand/views/product_template_views.xml diff --git a/quantity_on_hand/__init__.py b/quantity_on_hand/__init__.py new file mode 100644 index 00000000000..d6210b1285d --- /dev/null +++ b/quantity_on_hand/__init__.py @@ -0,0 +1,3 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import models diff --git a/quantity_on_hand/__manifest__.py b/quantity_on_hand/__manifest__.py new file mode 100644 index 00000000000..4c8a482a786 --- /dev/null +++ b/quantity_on_hand/__manifest__.py @@ -0,0 +1,13 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +{ + 'name': 'Quantity on hand', + 'version': '1.0', + 'depends': ['stock'], + 'installable': True, + 'author': 'arkp', + 'data': [ + 'views/product_template_views.xml', + ], + 'license': 'LGPL-3', +} diff --git a/quantity_on_hand/models/__init__.py b/quantity_on_hand/models/__init__.py new file mode 100644 index 00000000000..740c8b22d3b --- /dev/null +++ b/quantity_on_hand/models/__init__.py @@ -0,0 +1,3 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import product_template diff --git a/quantity_on_hand/models/product_template.py b/quantity_on_hand/models/product_template.py new file mode 100644 index 00000000000..474404ba629 --- /dev/null +++ b/quantity_on_hand/models/product_template.py @@ -0,0 +1,21 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import api, fields, models + + +class ProductTemplate(models.Model): + _inherit = 'product.template' + + is_multilocation = fields.Boolean(compute="_compute_is_multilocation") + + @api.depends('product_variant_ids.stock_quant_ids.location_id') + def _compute_is_multilocation(self): + for record in self: + internal_location_ids = { + loc.id + for loc in record.mapped( + 'product_variant_ids.stock_quant_ids.location_id' + ) + if loc.usage == 'internal' + } + record.is_multilocation = len(internal_location_ids) > 1 diff --git a/quantity_on_hand/views/product_template_views.xml b/quantity_on_hand/views/product_template_views.xml new file mode 100644 index 00000000000..8d3175a96fa --- /dev/null +++ b/quantity_on_hand/views/product_template_views.xml @@ -0,0 +1,78 @@ + + + + product.template.form.custom.inherit + product.template + + + + + 1 + + + + 1 + + + + virtual_available < 0 + virtual_available == 0 + + + + Forecasted + + + + + + + + + + + 1 + + + + + + + product.template.common.form.inherit + product.template + + + + + type == 'consu' + + + + + + + + + + + + + + \ No newline at end of file