From 410dcffb29d877bb5f6c59c021f8475bd7caa1a4 Mon Sep 17 00:00:00 2001 From: Sergi Almacellas Abellana Date: Mon, 30 Mar 2020 09:37:30 +0200 Subject: [PATCH] Add visual on product and location quantities issue8982 review301191009 --- CHANGELOG | 1 + location.py | 15 +++++++++++++++ product.py | 9 +++++++++ 3 files changed, 25 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index d71e28c569..d820dee1e6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Add visual on product and location quantities * Define one lost and found location per warehouse * Show warehouse in user status if not unique * Add cost price revision diff --git a/location.py b/location.py index aee68eb76d..7a0cde7705 100644 --- a/location.py +++ b/location.py @@ -552,6 +552,21 @@ class Location(DeactivableMixin, tree(), ModelSQL, ModelView): res.append(new_location) return res + @classmethod + def view_attributes(cls): + storage_types = Eval('type').in_(['storage', 'warehouse', 'view']) + return super().view_attributes() + [ + ('/tree/field[@name="quantity"]', + 'visual', If( + storage_types & (Eval('quantity', 0) < 0), 'danger', ''), + ['type']), + ('/tree/field[@name="forecast_quantity"]', + 'visual', If( + storage_types & (Eval('forecast_quantity', 0) < 0), + 'warning', ''), + ['type']), + ] + supplier_location = fields.Many2One( 'stock.location', "Supplier Location", domain=[('type', '=', 'supplier')], diff --git a/product.py b/product.py index d066146fd4..88157df380 100644 --- a/product.py +++ b/product.py @@ -384,6 +384,15 @@ class Product(StockMixin, object, metaclass=PoolMeta): cost_price = revision.get_cost_price(cost_price) return cost_price + @classmethod + def view_attributes(cls): + return super().view_attributes() + [ + ('/tree/field[@name="quantity"]', + 'visual', If(Eval('quantity', 0) < 0, 'danger', '')), + ('/tree/field[@name="forecast_quantity"]', + 'visual', If(Eval('forecast_quantity', 0) < 0, 'warning', '')), + ] + class ProductByLocationContext(ModelView): 'Product by Location'