From cf4b1b857d94bb03c59137b6fbe3af794bd2b483 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 22 Feb 2008 12:58:10 +0100 Subject: [PATCH] Add context to the evaluation of states and add readonly state for buttons --- tryton/gui/window/view_form/view/form.py | 3 ++- tryton/gui/window/view_form/view/form_gtk/parser.py | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tryton/gui/window/view_form/view/form.py b/tryton/gui/window/view_form/view/form.py index 1584592ba6..1163f02b3b 100644 --- a/tryton/gui/window/view_form/view/form.py +++ b/tryton/gui/window/view_form/view/form.py @@ -178,7 +178,8 @@ class ViewForm(ParserView): def display(self): model = self.screen.current_model - values = {'state': 'draft'} + values = rpc.session.context.copy() + values['state'] = 'draft' if model: for field in model.mgroup.fields: values[field] = model[field].get(model, check_load=False) diff --git a/tryton/gui/window/view_form/view/form_gtk/parser.py b/tryton/gui/window/view_form/view/form_gtk/parser.py index de0ff62ed6..f0ff8550d8 100644 --- a/tryton/gui/window/view_form/view/form_gtk/parser.py +++ b/tryton/gui/window/view_form/view/form_gtk/parser.py @@ -77,6 +77,13 @@ class Button(object): self.widget.show() else: self.widget.show() + if 'readonly' in state_changes: + if eval(state_changes['readonly'], values): + self.widget.set_sensitive(False) + else: + self.widget.set_sensitive(True) + else: + self.widget.set_sensitive(True) class Label(gtk.Label):