From 94e9d784fb2ad65570fce2dd2c855a219fa2e2ba Mon Sep 17 00:00:00 2001 From: Sergi Almacellas Abellana Date: Mon, 19 Feb 2018 11:41:53 +0100 Subject: [PATCH] Add depends on Button issue6919 review40811002 --- inventory.py | 3 +++ move.py | 4 ++++ period.py | 2 ++ shipment.py | 24 ++++++++++++++++++++++++ view/move_form.xml | 1 - 5 files changed, 33 insertions(+), 1 deletion(-) diff --git a/inventory.py b/inventory.py index cee467fdbf..bfafce4788 100644 --- a/inventory.py +++ b/inventory.py @@ -71,12 +71,15 @@ class Inventory(Workflow, ModelSQL, ModelView): cls._buttons.update({ 'confirm': { 'invisible': Eval('state').in_(['done', 'cancel']), + 'depends': ['state'], }, 'cancel': { 'invisible': Eval('state').in_(['cancel', 'done']), + 'depends': ['state'], }, 'complete_lines': { 'readonly': Eval('state') != 'draft', + 'depends': ['state'], }, }) diff --git a/move.py b/move.py index f1fe4ce004..0a6be71c41 100644 --- a/move.py +++ b/move.py @@ -294,19 +294,23 @@ class Move(Workflow, ModelSQL, ModelView): 'cancel': { 'invisible': ~Eval('state').in_(['draft', 'assigned']), 'readonly': Eval('shipment'), + 'depends': ['state', 'shipment'], }, 'draft': { 'invisible': ~Eval('state').in_(['assigned']), 'readonly': Eval('shipment'), + 'depends': ['state', 'shipment'], }, 'assign': { 'invisible': ~Eval('state').in_(['assigned']), + 'depends': ['state'], }, 'do': { 'invisible': ~Eval('state').in_(['draft', 'assigned']), 'readonly': (Eval('shipment') | (Eval('assignation_required', True) & (Eval('state') == 'draft'))), + 'depends': ['state', 'assignation_required', 'shipment'], }, }) diff --git a/period.py b/period.py index 9e91b4413e..c187aee680 100644 --- a/period.py +++ b/period.py @@ -48,9 +48,11 @@ class Period(Workflow, ModelSQL, ModelView): cls._buttons.update({ 'draft': { 'invisible': Eval('state') == 'draft', + 'depends': ['state'], }, 'close': { 'invisible': Eval('state') == 'closed', + 'depends': ['state'], }, }) diff --git a/shipment.py b/shipment.py index 1b6b766872..ec7c8b17fb 100644 --- a/shipment.py +++ b/shipment.py @@ -188,15 +188,19 @@ class ShipmentIn(Workflow, ModelSQL, ModelView): cls._buttons.update({ 'cancel': { 'invisible': Eval('state').in_(['cancel', 'done']), + 'depends': ['state'], }, 'draft': { 'invisible': Eval('state') != 'cancel', + 'depends': ['state'], }, 'receive': { 'invisible': Eval('state') != 'draft', + 'depends': ['state'], }, 'done': { 'invisible': Eval('state') != 'received', + 'depends': ['state'], }, }) @@ -623,22 +627,27 @@ class ShipmentInReturn(Workflow, ModelSQL, ModelView): cls._buttons.update({ 'cancel': { 'invisible': Eval('state').in_(['cancel', 'done']), + 'depends': ['state'], }, 'draft': { 'invisible': ~Eval('state').in_(['waiting', 'cancel']), 'icon': If(Eval('state') == 'cancel', 'tryton-clear', 'tryton-go-previous'), + 'depends': ['state'], }, 'wait': { 'invisible': ~Eval('state').in_(['assigned', 'draft']), 'icon': If(Eval('state') == 'assigned', 'tryton-go-previous', 'tryton-go-next'), + 'depends': ['state'], }, 'done': { 'invisible': Eval('state') != 'assigned', + 'depends': ['state'], }, 'assign_wizard': { 'invisible': Eval('state') != 'waiting', + 'depends': ['state'], }, 'assign_try': {}, 'assign_force': {}, @@ -978,11 +987,13 @@ class ShipmentOut(Workflow, ModelSQL, ModelView): cls._buttons.update({ 'cancel': { 'invisible': Eval('state').in_(['cancel', 'done']), + 'depends': ['state'], }, 'draft': { 'invisible': ~Eval('state').in_(['waiting', 'cancel']), 'icon': If(Eval('state') == 'cancel', 'tryton-clear', 'tryton-go-previous'), + 'depends': ['state'], }, 'wait': { 'invisible': ~Eval('state').in_(['assigned', 'waiting', @@ -992,12 +1003,15 @@ class ShipmentOut(Workflow, ModelSQL, ModelView): If(Eval('state') == 'waiting', 'tryton-clear', 'tryton-go-next')), + 'depends': ['state'], }, 'pack': { 'invisible': If(Eval('warehouse_storage') == Eval('warehouse_output'), ~Eval('state').in_(['assigned', 'waiting']), Eval('state') != 'assigned'), + 'depends': ['state', 'warehouse_storage', + 'warehouse_output'], }, 'done': { 'invisible': Eval('state') != 'packed', @@ -1561,15 +1575,19 @@ class ShipmentOutReturn(Workflow, ModelSQL, ModelView): cls._buttons.update({ 'cancel': { 'invisible': Eval('state').in_(['cancel', 'done']), + 'depends': ['state'], }, 'draft': { 'invisible': Eval('state') != 'cancel', + 'depends': ['state'], }, 'receive': { 'invisible': Eval('state') != 'draft', + 'depends': ['state'], }, 'done': { 'invisible': Eval('state') != 'received', + 'depends': ['state'], }, }) @@ -2076,6 +2094,7 @@ class ShipmentInternal(Workflow, ModelSQL, ModelView): 'cancel': { 'invisible': Eval('state').in_( ['cancel', 'shipped', 'done']), + 'depends': ['state'], }, 'draft': { 'invisible': ~Eval('state').in_( @@ -2085,6 +2104,7 @@ class ShipmentInternal(Workflow, ModelSQL, ModelView): If(Eval('state') == 'request', 'tryton-go-next', 'tryton-go-previous')), + 'depends': ['state'], }, 'wait': { 'invisible': ~Eval('state').in_(['assigned', 'waiting', @@ -2094,19 +2114,23 @@ class ShipmentInternal(Workflow, ModelSQL, ModelView): If(Eval('state') == 'waiting', 'tryton-clear', 'tryton-go-next')), + 'depends': ['state'], }, 'ship': { 'invisible': ((Eval('state') != 'assigned') | ~Eval('transit_location')), + 'depends': ['state', 'transit_location'], }, 'done': { 'invisible': If( ~Eval('transit_location'), Eval('state') != 'assigned', Eval('state') != 'shipped'), + 'depends': ['state', 'transit_location'], }, 'assign_wizard': { 'invisible': Eval('state') != 'waiting', + 'depends': ['state'], }, 'assign_try': {}, 'assign_force': {}, diff --git a/view/move_form.xml b/view/move_form.xml index 7f77800030..1b49e995ea 100644 --- a/view/move_form.xml +++ b/view/move_form.xml @@ -35,5 +35,4 @@ this repository contains the full copyright notices and license terms. --> -