From 8d247621fb7a6b96ff9ca978f2ff292e899af10b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 13 Apr 2012 13:20:14 +0200 Subject: [PATCH] Don't call default_get for new record from on_change This is to have the same behavior as the client. The default values must be managed by the values of the on_change review323001 --- proteus/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/proteus/__init__.py b/proteus/__init__.py index 4b7b065aeb..a3103bb559 100644 --- a/proteus/__init__.py +++ b/proteus/__init__.py @@ -506,7 +506,7 @@ class Model(object): _config = None _fields = None - def __init__(self, id=None, **kwargs): + def __init__(self, id=None, _default=True, **kwargs): super(Model, self).__init__() if id: assert not kwargs @@ -518,7 +518,7 @@ class Model(object): self._parent = None # store the parent record self._parent_field_name = '' # store the field name in parent record self._parent_name = '' # store the field name to parent record - if self.id < 0: + if self.id < 0 and _default: self._default_get() for field_name, value in kwargs.iteritems(): @@ -735,7 +735,7 @@ class Model(object): for vals in value.get('add', []): relation = Model.get(self._fields[field]['relation'], self._config) - record = relation() + record = relation(_default=False) for i, j in vals.iteritems(): if '.' in i: continue