diff --git a/share/pixmaps/tryton.png b/share/pixmaps/tryton.png index c77e745158..d3435e5501 100644 Binary files a/share/pixmaps/tryton.png and b/share/pixmaps/tryton.png differ diff --git a/tryton/gui/window/view_form/model/field.py b/tryton/gui/window/view_form/model/field.py index 4258261f5e..cb39719467 100644 --- a/tryton/gui/window/view_form/model/field.py +++ b/tryton/gui/window/view_form/model/field.py @@ -70,6 +70,10 @@ class CharField(object): def get(self, model, check_load=True, readonly=True, modified=False): return model.value.get(self.name, False) or False + def get_eval(self, model, check_load=True): + return self.get(model, check_load=check_load, readonly=True, + modified=False) + def set_client(self, model, value, test_state=True, force_change=False): internal = model.value.get(self.name, False) self.set(model, value, test_state) @@ -278,6 +282,10 @@ class M2MField(CharField): def get(self, model, check_load=True, readonly=True, modified=False): return [('set', model.value[self.name] or [])] + def get_eval(self, model, check_load=True): + return self.get(model, check_load=check_load, readonly=True, + modified=False)[0][1] + def get_client(self, model): return model.value[self.name] or [] @@ -346,6 +354,14 @@ class O2MField(CharField): result.append(('delete', model.value[self.name].model_deleted)) return result + def get_eval(self, model, check_load=True): + result = [] + if not model.value[self.name]: + return [] + for model2 in model.value[self.name].models: + result.append(model2.get_eval(check_load=check_load)) + return result + def set(self, model, value, test_state=False, modified=False): from group import ModelRecordGroup mod = ModelRecordGroup(self.attrs['relation'], {}, model.window, diff --git a/tryton/gui/window/view_form/model/group.py b/tryton/gui/window/view_form/model/group.py index 6b70342297..02e46b4bf0 100644 --- a/tryton/gui/window/view_form/model/group.py +++ b/tryton/gui/window/view_form/model/group.py @@ -285,7 +285,7 @@ class ModelRecordGroup(SignalEvent): return None return self.models[self.current_idx] - def remove(self, model, remove=False): + def remove(self, model, remove=False, modified=True): idx = self.models.index(model) if self.models[idx].id: if remove: @@ -294,7 +294,10 @@ class ModelRecordGroup(SignalEvent): self.model_deleted.append(self.models[idx].id) if model.parent: model.parent.modified = True + if modified: + model.modified = True self.models.remove(self.models[idx]) + model.signal('record-changed', model.parent) def add_fields_custom(self, fields, models): to_add = [] @@ -325,7 +328,7 @@ class ModelRecordGroup(SignalEvent): if model.id: if model.is_modified(): old.append(model.id) - else: + elif to_add: model._loaded = False else: new.append(model) diff --git a/tryton/gui/window/view_form/model/record.py b/tryton/gui/window/view_form/model/record.py index bd8b05d8c1..4b6be183f7 100644 --- a/tryton/gui/window/view_form/model/record.py +++ b/tryton/gui/window/view_form/model/record.py @@ -11,17 +11,14 @@ import tryton.common as common class EvalEnvironment(object): - def __init__(self, parent): + def __init__(self, parent, check_load): self.parent = parent + self.check_load = check_load def __getattr__(self, item): if item == 'parent' and self.parent.parent: return EvalEnvironment(self.parent.parent) - if item == "current_date": - return datetime.datetime.today() - if item == "time": - return time - return self.parent.get(includeid=True)[item] + return self.parent.get_eval(check_load=self.check_load)[item] class ModelRecord(SignalEvent): @@ -123,6 +120,15 @@ class ModelRecord(SignalEvent): value['id'] = self.id return value + def get_eval(self, check_load=True): + if check_load: + self._check_load() + value = {} + for name, mfield in self.mgroup.mfields.items(): + value[name] = mfield.get_eval(self, check_load=check_load) + value['id'] = self.id + return value + def cancel(self): self._loaded = False self.reload() @@ -264,21 +270,21 @@ class ModelRecord(SignalEvent): self.read_time = time.time() self.set(value) - def expr_eval(self, dom, check_load=True): + def expr_eval(self, dom, check_load=False): if not isinstance(dom, basestring): return dom if check_load: self._check_load() ctx = rpc.CONTEXT.copy() for name, mfield in self.mgroup.mfields.items(): - ctx[name] = mfield.get(self, check_load=check_load) + ctx[name] = mfield.get_eval(self, check_load=check_load) ctx['current_date'] = datetime.datetime.today() ctx['time'] = time ctx['context'] = self.context_get() ctx['active_id'] = self.id if self.parent: - ctx['parent'] = EvalEnvironment(self.parent) + ctx['parent'] = EvalEnvironment(self.parent, check_load) val = eval(dom, ctx) return val 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 1dea0e432e..2ea34bf83e 100644 --- a/tryton/gui/window/view_form/view/form_gtk/checkbox.py +++ b/tryton/gui/window/view_form/view/form_gtk/checkbox.py @@ -9,6 +9,7 @@ class CheckBox(WidgetInterface): self.widget = gtk.CheckButton() self.widget.connect('focus-in-event', lambda x, y: self._focus_in()) self.widget.connect('focus-out-event', lambda x, y: self._focus_out()) + self.widget.connect('button_press_event', self._menu_open) self.widget.connect_after('toggled', self.sig_activate) def _readonly_set(self, value): diff --git a/tryton/pysocket.py b/tryton/pysocket.py index cddcee9ef8..5b4276d979 100644 --- a/tryton/pysocket.py +++ b/tryton/pysocket.py @@ -8,6 +8,8 @@ except ImportError: import StringIO DNS_CACHE = {} +MAX_SIZE = 999999999 +MAX_LENGHT = len(str(MAX_SIZE)) _ALLOWED_MODULES = {'datetime': ['datetime', 'date'], 'decimal': ['Decimal']} @@ -117,9 +119,9 @@ class PySocket: msg = cPickle.dumps([msg, traceback], protocol=2) size = len(msg) if self.ssl: - self.ssl_sock.write('%8d' % size) + self.ssl_sock.write(str(size) + ' ') else: - self.sock.send('%8d' % size) + self.sock.send(str(size) + ' ') if self.ssl: self.ssl_sock.write(exception and "1" or "0") else: @@ -136,29 +138,35 @@ class PySocket: def receive(self): buf = '' - while len(buf) < 8: + while len(buf) < MAX_LENGHT: if self.ssl: - chunk = self.ssl_sock.read(8 - len(buf)) + chunk = self.ssl_sock.read(MAX_LENGHT - len(buf)) else: - chunk = self.sock.recv(8 - len(buf)) + chunk = self.sock.recv(MAX_LENGHT - len(buf)) if chunk == '': raise RuntimeError, "socket connection broken" buf += chunk - size = int(buf) - if self.ssl: - buf = self.ssl_sock.read(1) - else: - buf = self.sock.recv(1) - if buf != "0": + if ' ' in buf: + break + size, msg = buf.split(' ', 1) + size = int(size) + if msg == '': + if self.ssl: + msg = self.ssl_sock.read(1) + else: + msg = self.sock.recv(1) + if msg == '': + raise RuntimeError, "socket connection broken" + if msg[0] != "0": exception = buf else: exception = False - msg = '' + msg = msg[1:] while len(msg) < size: if self.ssl: - chunk = self.ssl_sock.read(size-len(msg)) + chunk = self.ssl_sock.read(size - len(msg)) else: - chunk = self.sock.recv(size-len(msg)) + chunk = self.sock.recv(size - len(msg)) if chunk == '': raise RuntimeError, "socket connection broken" msg = msg + chunk