diff --git a/tryton/gui/window/view_form/model/field.py b/tryton/gui/window/view_form/model/field.py index 7c78be5696..44da4e5272 100644 --- a/tryton/gui/window/view_form/model/field.py +++ b/tryton/gui/window/view_form/model/field.py @@ -388,6 +388,14 @@ class M2MField(CharField): def get_default(self, model): return self.get_client(model) + def name_get(self, model): + rpc2 = RPCProxy(self.attrs['relation']) + try: + result = rpc2.name_get(self.get_client(model), rpc.CONTEXT) + except: + return self.get_client(model) + return ', '.join(dict(result).values()) + class O2MField(CharField): ''' diff --git a/tryton/gui/window/view_form/view/form_gtk/binary.py b/tryton/gui/window/view_form/view/form_gtk/binary.py index 58f90aa83d..d504e242a4 100644 --- a/tryton/gui/window/view_form/view/form_gtk/binary.py +++ b/tryton/gui/window/view_form/view/form_gtk/binary.py @@ -114,6 +114,9 @@ class Binary(WidgetInterface): self.but_save_as.set_sensitive(bool(model_field.get(model))) return True + def display_value(self): + return self.wid_text.get_text() + def _size_get(self, value): return value and ('%d ' + _('bytes')) % len(value) or '' diff --git a/tryton/gui/window/view_form/view/form_gtk/calendar.py b/tryton/gui/window/view_form/view/form_gtk/calendar.py index ab3deaaed5..f4ca5c543f 100644 --- a/tryton/gui/window/view_form/view/form_gtk/calendar.py +++ b/tryton/gui/window/view_form/view/form_gtk/calendar.py @@ -105,6 +105,9 @@ class Calendar(WidgetInterface): self.entry.set_text(value) return True + def display_value(self): + return self.entry.get_text() + def cal_open(self, widget): win = gtk.Dialog(_('Date Selection'), self._window, gtk.DIALOG_MODAL|gtk.DIALOG_DESTROY_WITH_PARENT, @@ -260,6 +263,9 @@ class DateTime(WidgetInterface): self.entry.set_text(value) return True + def display_value(self): + return self.entry.get_text() + def cal_open(self, widget): win = gtk.Dialog(_('Date Time Selection'), self._window, gtk.DIALOG_MODAL|gtk.DIALOG_DESTROY_WITH_PARENT, diff --git a/tryton/gui/window/view_form/view/form_gtk/checkbox.py b/tryton/gui/window/view_form/view/form_gtk/checkbox.py index 2ea34bf83e..423e90bff9 100644 --- a/tryton/gui/window/view_form/view/form_gtk/checkbox.py +++ b/tryton/gui/window/view_form/view/form_gtk/checkbox.py @@ -1,6 +1,9 @@ #This file is part of Tryton. The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms. import gtk from interface import WidgetInterface +import gettext + +_ = gettext.gettext class CheckBox(WidgetInterface): @@ -25,3 +28,9 @@ class CheckBox(WidgetInterface): self.widget.set_active(False) return False self.widget.set_active(bool(model_field.get(model))) + + def display_value(self): + if self.widget.get_active(): + return _('True') + else: + return _('False') diff --git a/tryton/gui/window/view_form/view/form_gtk/float_time.py b/tryton/gui/window/view_form/view/form_gtk/float_time.py index dc25c8f2c2..47f19fc06a 100644 --- a/tryton/gui/window/view_form/view/form_gtk/float_time.py +++ b/tryton/gui/window/view_form/view/form_gtk/float_time.py @@ -60,6 +60,9 @@ class FloatTime(WidgetInterface): value = '-' + value self.entry.set_text(value) + def display_value(self): + return self.entry.get_text() + def _readonly_set(self, value): super(FloatTime, self)._readonly_set(value) self.entry.set_editable(not value) diff --git a/tryton/gui/window/view_form/view/form_gtk/integer.py b/tryton/gui/window/view_form/view/form_gtk/integer.py index 901bab68cf..ecf915d891 100644 --- a/tryton/gui/window/view_form/view/form_gtk/integer.py +++ b/tryton/gui/window/view_form/view/form_gtk/integer.py @@ -1,4 +1,5 @@ -#This file is part of Tryton. The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms. +#This file is part of Tryton. The COPYRIGHT file at the top level of +#this repository contains the full copyright notices and license terms. from char import Char import locale @@ -27,6 +28,9 @@ class Integer(Char): self.entry.set_text(locale.format('%d', model_field.get(model) or 0, True)) + def display_value(self): + return self.entry.get_text() + def sig_insert_text(self, entry, new_text, new_text_length, position): value = entry.get_text() position = entry.get_position() diff --git a/tryton/gui/window/view_form/view/form_gtk/interface.py b/tryton/gui/window/view_form/view/form_gtk/interface.py index 97ab6099e0..fcc31c9fb7 100644 --- a/tryton/gui/window/view_form/view/form_gtk/interface.py +++ b/tryton/gui/window/view_form/view/form_gtk/interface.py @@ -16,16 +16,15 @@ _ATTRS_BOOLEAN = { 'readonly': False } -def field_pref_set(field, name, model, value, dependance=None, window=None): +def field_pref_set(field, name, model, value, client_value, dependance=None, + window=None): dialog = WidgetFieldPreference(window) if dependance is None: dependance = [] entry = dialog.entry_field_name entry.set_text(name) - entry = dialog.entry_domain - entry.set_text(model) entry = dialog.entry_default_value - entry.set_text((value and str(value)) or _('')) + entry.set_text((client_value and str(client_value)) or _('')) radio = dialog.radio_current_user @@ -188,10 +187,14 @@ class WidgetInterface(object): value = wview.modelfield.get_client(self._view.model) deps.append((wname, name, wvalue, value)) value = self._view.modelfield.get_default(self._view.model) + client_value = self.display_value() model = self._view.modelfield.parent.resource field_pref_set(self._view.widget_name, self.attrs.get('string', self._view.widget_name), model, - value, deps, window=self._window) + value, client_value, deps, window=self._window) + + def display_value(self): + return self._view.modelfield.get_client(self._view.model) def _menu_open(self, obj, event): if event.button == 3: diff --git a/tryton/gui/window/view_form/view/form_gtk/many2many.py b/tryton/gui/window/view_form/view/form_gtk/many2many.py index 58589d754a..fe7b7452b8 100644 --- a/tryton/gui/window/view_form/view/form_gtk/many2many.py +++ b/tryton/gui/window/view_form/view/form_gtk/many2many.py @@ -1,4 +1,5 @@ -#This file is part of Tryton. The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms. +#This file is part of Tryton. The COPYRIGHT file at the top level of +#this repository contains the full copyright notices and license terms. import gtk from tryton.gui.window.view_form.screen import Screen from interface import WidgetInterface @@ -128,5 +129,8 @@ class Many2Many(WidgetInterface): self.screen.display() return True + def display_value(self): + return self._view.modelfield.name_get(self._view.model) + def set_value(self, model, model_field): model_field.set_client(model, [x.id for x in self.screen.models.models]) diff --git a/tryton/gui/window/view_form/view/form_gtk/one2many.py b/tryton/gui/window/view_form/view/form_gtk/one2many.py index 28a9846c26..757f57437e 100644 --- a/tryton/gui/window/view_form/view/form_gtk/one2many.py +++ b/tryton/gui/window/view_form/view/form_gtk/one2many.py @@ -654,6 +654,9 @@ class One2Many(WidgetInterface): self.screen.display() return True + def display_value(self): + return '<' + self.attrs.get('string', '') + '>' + def set_value(self, model, model_field): self.screen.current_view.set_value() if self.screen.is_modified(): diff --git a/tryton/gui/window/view_form/view/form_gtk/preference.py b/tryton/gui/window/view_form/view/form_gtk/preference.py index 9808302753..247c1753b7 100644 --- a/tryton/gui/window/view_form/view/form_gtk/preference.py +++ b/tryton/gui/window/view_form/view/form_gtk/preference.py @@ -16,7 +16,7 @@ class WidgetFieldPreference(object): def __init__(self, window): self.parent = window self.dialog = gtk.Dialog( - title=_("Field Preference target"), + title=_("Field Preference"), parent=window, flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT | gtk.WIN_POS_CENTER_ON_PARENT) @@ -33,10 +33,10 @@ class WidgetFieldPreference(object): self.dialog.set_default_response(gtk.RESPONSE_OK) vbox = gtk.VBox() self.dialog.vbox.pack_start(vbox) - table = gtk.Table(5, 2, False) + table = gtk.Table(4, 2, False) table.set_border_width(4) table.set_row_spacings(4) - table.set_col_spacings(5) + table.set_col_spacings(4) vbox.pack_start(table, True, True, 0) label_field_name = gtk.Label(_("Field Name:")) @@ -45,20 +45,28 @@ class WidgetFieldPreference(object): table.attach(label_field_name, 0, 1, 0, 1) self.entry_field_name = gtk.Entry() self.entry_field_name.set_editable(False) + style = self.entry_field_name.get_style() + self.entry_field_name.modify_bg(gtk.STATE_NORMAL, + style.bg[gtk.STATE_INSENSITIVE]) + self.entry_field_name.modify_base(gtk.STATE_NORMAL, + style.base[gtk.STATE_INSENSITIVE]) + self.entry_field_name.modify_fg(gtk.STATE_NORMAL, + style.fg[gtk.STATE_INSENSITIVE]) table.attach(self.entry_field_name, 1, 2, 0, 1) - label_domain = gtk.Label(_("Domain:")) - label_domain.set_justify(gtk.JUSTIFY_RIGHT) - label_domain.set_alignment(1, 0.5) - table.attach(label_domain, 0, 1, 1, 2) - self.entry_domain = gtk.Entry() - self.entry_domain.set_editable(False) - table.attach(self.entry_domain, 1, 2, 1, 2) label_default_value = gtk.Label(_("Default value:")) label_default_value.set_alignment(1, 0.5) - table.attach(label_default_value, 0, 1, 2, 3) + table.attach(label_default_value, 0, 1, 1, 2) self.entry_default_value = gtk.Entry() self.entry_default_value.set_editable(False) - table.attach(self.entry_default_value, 1, 2, 2, 3) + self.entry_default_value.set_width_chars(32) + style = self.entry_field_name.get_style() + self.entry_default_value.modify_bg(gtk.STATE_NORMAL, + style.bg[gtk.STATE_INSENSITIVE]) + self.entry_default_value.modify_base(gtk.STATE_NORMAL, + style.base[gtk.STATE_INSENSITIVE]) + self.entry_default_value.modify_fg(gtk.STATE_NORMAL, + style.fg[gtk.STATE_INSENSITIVE]) + table.attach(self.entry_default_value, 1, 2, 1, 2) frame_user = gtk.Frame() alignment_user = gtk.Alignment(0.5, 0.5, 1, 1) @@ -70,13 +78,13 @@ class WidgetFieldPreference(object): hbox_user = gtk.HBox(True, 0) alignment_user.add(hbox_user) hbox_user.set_border_width(6) - self.radio_current_user = gtk.RadioButton(None, _("current _user")) + self.radio_current_user = gtk.RadioButton(None, _("Current _User")) radio_all_user = gtk.RadioButton(self.radio_current_user, - _("_all users")) + _("_All Users")) hbox_user.pack_start(self.radio_current_user, False, False, 0) hbox_user.pack_start(radio_all_user, False, False, 0) radio_all_user.set_active(True) - table.attach(frame_user, 0, 2, 3, 4) + table.attach(frame_user, 0, 2, 2, 3) frame_condition = gtk.Frame() alignment_condition = gtk.Alignment(0.5, 0.5, 1, 1) @@ -87,7 +95,7 @@ class WidgetFieldPreference(object): frame_condition.set_label_widget(label_condition) self.vbox_condition = gtk.VBox(False, 0) alignment_condition.add(self.vbox_condition) - table.attach(frame_condition, 0, 2, 4, 5) + table.attach(frame_condition, 0, 2, 3, 4) self.dialog.show_all() radio_all_user.grab_focus() diff --git a/tryton/gui/window/view_form/view/form_gtk/progressbar.py b/tryton/gui/window/view_form/view/form_gtk/progressbar.py index 4bb29f38f8..81153bcaef 100644 --- a/tryton/gui/window/view_form/view/form_gtk/progressbar.py +++ b/tryton/gui/window/view_form/view/form_gtk/progressbar.py @@ -35,3 +35,6 @@ class ProgressBar(WidgetInterface): self.widget.set_text(locale.format('%.' + str(digits[1]) + 'f', value, True)) self.widget.set_fraction(value / 100.0) + + def display_value(self): + return self.widget.get_text() diff --git a/tryton/gui/window/view_form/view/form_gtk/reference.py b/tryton/gui/window/view_form/view/form_gtk/reference.py index 43baeb1dff..19440702ab 100644 --- a/tryton/gui/window/view_form/view/form_gtk/reference.py +++ b/tryton/gui/window/view_form/view/form_gtk/reference.py @@ -289,6 +289,10 @@ class Reference(WidgetInterface): self.but_open.set_image(img) self.changed = True + def display_value(self): + return self.widget_combo.get_child().get_text() + ', ' + \ + self.wid_text.get_text() + def sig_key_pressed(self, *args): key = args[1].string.lower() if self.last_key[0] == key: diff --git a/tryton/gui/window/view_form/view/form_gtk/selection.py b/tryton/gui/window/view_form/view/form_gtk/selection.py index 6102366ed6..82c3b3929f 100644 --- a/tryton/gui/window/view_form/view/form_gtk/selection.py +++ b/tryton/gui/window/view_form/view/form_gtk/selection.py @@ -136,6 +136,9 @@ class Selection(WidgetInterface): break self.changed = True + def display_value(self): + return self.entry.get_child().get_text() + def sig_changed(self, *args): if self.changed: self._focus_out() diff --git a/tryton/gui/window/view_form/view/form_gtk/textbox.py b/tryton/gui/window/view_form/view/form_gtk/textbox.py index e2149edaa3..42a9a0b51d 100644 --- a/tryton/gui/window/view_form/view/form_gtk/textbox.py +++ b/tryton/gui/window/view_form/view/form_gtk/textbox.py @@ -110,3 +110,10 @@ class TextBox(WidgetInterface): del spell except: pass + + def display_value(self): + lines = (self._view.modelfield.get_client(self._view.model) or '').split('\n') + if len(lines) > 1: + return lines[0] + '...' + else: + return lines[0]