changeset 4b08f841329c in modules/stock:default
details: https://hg.tryton.org/modules/stock?cmd=changeset;node=4b08f841329c
description:
        Add visual on product and location quantities

        issue8982
        review301191009
diffstat:

 CHANGELOG   |   1 +
 location.py |  15 +++++++++++++++
 product.py  |   9 +++++++++
 3 files changed, 25 insertions(+), 0 deletions(-)

diffs (52 lines):

diff -r 698fa41886bb -r 4b08f841329c CHANGELOG
--- a/CHANGELOG Thu Mar 19 19:13:34 2020 +0100
+++ b/CHANGELOG Mon Mar 30 09:37:30 2020 +0200
@@ -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 -r 698fa41886bb -r 4b08f841329c location.py
--- a/location.py       Thu Mar 19 19:13:34 2020 +0100
+++ b/location.py       Mon Mar 30 09:37:30 2020 +0200
@@ -552,6 +552,21 @@
             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 -r 698fa41886bb -r 4b08f841329c product.py
--- a/product.py        Thu Mar 19 19:13:34 2020 +0100
+++ b/product.py        Mon Mar 30 09:37:30 2020 +0200
@@ -384,6 +384,15 @@
             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'

Reply via email to