From d0a2b6b3da57e04fc0cdd44b2e7175cf212ebe78 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Thu, 14 Aug 2014 18:19:48 +0200 Subject: [PATCH] [FIX] models: stored func fields computation on one2many write On one2many fields writing in an existing record (not when creating new record), the computed stored fields of the one2many were not re-computed correctly Computed stored fields were marked as modified only if no_store_function was not set to True in the context. no_store_function is set when writing one2many records on an existing record. Now, these computed stored fields are marked as to be recomputed, but are recomputed later, at the end of the existing record write --- openerp/models.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/openerp/models.py b/openerp/models.py index ae366aa647e..500fda28dd9 100644 --- a/openerp/models.py +++ b/openerp/models.py @@ -4109,6 +4109,12 @@ class BaseModel(object): # check Python constraints recs._validate_fields(vals) + # Mark new-style fields to recompute + modified_fields = list(vals) + if self._log_access: + modified_fields += ['create_uid', 'create_date', 'write_uid', 'write_date'] + recs.modified(modified_fields) + if not context.get('no_store_function', False): result += self._store_get_values(cr, user, [id_new], list(set(vals.keys() + self._inherits.values())), @@ -4119,12 +4125,7 @@ class BaseModel(object): if not (model_name, ids, fields2) in done: self.pool[model_name]._store_set_values(cr, user, ids, fields2, context) done.append((model_name, ids, fields2)) - # recompute new-style fields - modified_fields = list(vals) - if self._log_access: - modified_fields += ['create_uid', 'create_date', 'write_uid', 'write_date'] - recs.modified(modified_fields) recs.recompute() if self._log_create and not (context and context.get('no_store_function', False)):