From e6e4e8d4c102f477c95415154a1411be54126f2a Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Mon, 22 Oct 2012 14:31:00 +0200 Subject: [PATCH] [REV] osv/orm: revert of a previous patch that was unifying the behavior for fields.related and fields.function at creation time because it's a bit dangereous to treat it right now, and may need the add of a new field attribute. "I'll be back", said the patch bzr revid: qdp-launchpad@openerp.com-20121022123100-wwr7lnmpqebddxon --- openerp/osv/orm.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py index 1db2feeca88..4c3330c97b7 100644 --- a/openerp/osv/orm.py +++ b/openerp/osv/orm.py @@ -4359,10 +4359,20 @@ class BaseModel(object): upd2.append(self._columns[field]._symbol_set[1](vals[field])) #for the function fields that receive a value, we set them directly in the database #(they may be required), but we also need to trigger the _fct_inv() - if (hasattr(self._columns[field], '_fnct_inv')): + if (hasattr(self._columns[field], '_fnct_inv')) and not isinstance(self._columns[field], fields.related): + #TODO: this way to special case the related fields is really creepy but it shouldn't be changed at + #one week of the release candidate. It seems the only good way to handle correctly this is to add an + #attribute to make a field `really readonly´ and thus totally ignored by the create()... otherwise + #if, for example, the related has a default value (for usability) then the fct_inv is called and it + #may raise some access rights error. Changing this is a too big change for now, and is thus postponed + #after the release but, definitively, the behavior shouldn't be different for related and function + #fields. upd_todo.append(field) else: - upd_todo.append(field) + #TODO: this `if´ statement should be removed because there is no good reason to special case the fields + #related. See the above TODO comment for further explanations. + if not isinstance(self._columns[field], fields.related): + upd_todo.append(field) if field in self._columns \ and hasattr(self._columns[field], 'selection') \ and vals[field]: