From 2c00a0639d48a47a4e4a306bf4ec5d1bd5264668 Mon Sep 17 00:00:00 2001 From: niyp-odoo Date: Wed, 23 Jul 2025 17:45:20 +0530 Subject: [PATCH] [IMP] inventory: improve stock info and UI in product form This improvement refines the product template form view to offer better stock visibility and user control, particularly for users operating in multi-company environments. The default buttons such as Update Quantity On Hand and Print Labels are hidden to reduce UI clutter and avoid confusion for non-storable or consumable products. A computed field is_multicompany has been added to restrict direct editing of stock quantities when the user is linked to multiple companies helping maintain data consistency. Additionally, the form now displays the current available quantity alongside its unit of measure with a clear Update button, making it easier for users to quickly act on stock changes. The Forecasted button label has also been clarified with an inline quantity display. Visual decorations on the virtual_available field indicate when stock is low or negative, allowing users to identify stock issues at a glance. A custom server action has been added to open the product replenish wizard, providing a fast and user-friendly way to restock products. Overall, these changes streamline the inventory management workflow and enhance the clarity and usability of the product form. task-4965097 --- update_on_hand/__init__.py | 1 + update_on_hand/__manifest__.py | 11 +++ update_on_hand/models/__init__.py | 1 + update_on_hand/models/product_template.py | 13 ++++ .../views/product_template_views.xml | 78 +++++++++++++++++++ 5 files changed, 104 insertions(+) create mode 100644 update_on_hand/__init__.py create mode 100644 update_on_hand/__manifest__.py create mode 100644 update_on_hand/models/__init__.py create mode 100644 update_on_hand/models/product_template.py create mode 100644 update_on_hand/views/product_template_views.xml diff --git a/update_on_hand/__init__.py b/update_on_hand/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/update_on_hand/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/update_on_hand/__manifest__.py b/update_on_hand/__manifest__.py new file mode 100644 index 00000000000..62284fcb841 --- /dev/null +++ b/update_on_hand/__manifest__.py @@ -0,0 +1,11 @@ +{ + 'name': 'Update Quantity On Hand', + 'version': '1.0', + 'author': 'niyp', + 'depends': ['stock'], + 'data': [ + 'views/product_template_views.xml', + ], + 'installable': True, + 'license': 'LGPL-3', +} diff --git a/update_on_hand/models/__init__.py b/update_on_hand/models/__init__.py new file mode 100644 index 00000000000..e8fa8f6bf1e --- /dev/null +++ b/update_on_hand/models/__init__.py @@ -0,0 +1 @@ +from . import product_template diff --git a/update_on_hand/models/product_template.py b/update_on_hand/models/product_template.py new file mode 100644 index 00000000000..6f0be1f6851 --- /dev/null +++ b/update_on_hand/models/product_template.py @@ -0,0 +1,13 @@ +from odoo import api, fields, models + + +class ProductTemplate(models.Model): + _inherit = 'product.template' + + is_multicompany = fields.Boolean(compute="_compute_is_multicompany") + + @api.depends('company_id') + def _compute_is_multicompany(self): + for record in self: + user = self.env.user + record.is_multicompany = len(user.company_ids) > 1 diff --git a/update_on_hand/views/product_template_views.xml b/update_on_hand/views/product_template_views.xml new file mode 100644 index 00000000000..34fad5e47da --- /dev/null +++ b/update_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' + + + + + + + + + + + + + +