diff --git a/openerp/models.py b/openerp/models.py index a9e229c3ba6..094d704f603 100644 --- a/openerp/models.py +++ b/openerp/models.py @@ -1040,6 +1040,8 @@ class BaseModel(object): :param dict context: :returns: {ids: list(int)|False, messages: [Message]} """ + if context is None: + context = {} cr.execute('SAVEPOINT model_load') messages = [] @@ -1094,6 +1096,10 @@ class BaseModel(object): if any(message['type'] == 'error' for message in messages): cr.execute('ROLLBACK TO SAVEPOINT model_load') ids = False + + if ids and context.get('defer_parent_store_computation'): + self._parent_store_compute(cr) + return {'ids': ids, 'messages': messages} def _add_fake_fields(self, cr, uid, fields, context=None): diff --git a/openerp/osv/expression.py b/openerp/osv/expression.py index 8b55fe3f646..71d5c4303c8 100644 --- a/openerp/osv/expression.py +++ b/openerp/osv/expression.py @@ -711,9 +711,11 @@ class expression(object): """ Return a domain implementing the child_of operator for [(left,child_of,ids)], either as a range using the parent_left/right tree lookup fields (when available), or as an expanded [(left,in,child_ids)] """ + if context is None: + context = {} if not ids: return FALSE_DOMAIN - if left_model._parent_store and (not left_model.pool._init): + if left_model._parent_store and (not left_model.pool._init) and (not context.get('defer_parent_store_computation')): # TODO: Improve where joins are implemented for many with '.', replace by: # doms += ['&',(prefix+'.parent_left','<',o.parent_right),(prefix+'.parent_left','>=',o.parent_left)] doms = [] @@ -736,7 +738,9 @@ class expression(object): """ Return a domain implementing the parent_of operator for [(left,parent_of,ids)], either as a range using the parent_left/right tree lookup fields (when available), or as an expanded [(left,in,parent_ids)] """ - if left_model._parent_store and (not left_model.pool._init): + if context is None: + context = {} + if left_model._parent_store and (not left_model.pool._init) and (not context.get('defer_parent_store_computation')): doms = [] for node in left_model.browse(cr, uid, ids, context=context): if doms: