Merge lp:~openerp-dev/openobject-server/7.0-updatenoupdatenotest-chs into lp:openobject-server/7.0

Proposed by Christophe Simonis (OpenERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-server/7.0-updatenoupdatenotest-chs
Merge into: lp:openobject-server/7.0
Diff against target: 62 lines (+23/-13)
1 file modified
openerp/addons/base/ir/ir_model.py (+23/-13)
To merge this branch: bzr merge lp:~openerp-dev/openobject-server/7.0-updatenoupdatenotest-chs
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+164324@code.launchpad.net
To post a comment you must log in.

Unmerged revisions

4976. By Christophe Simonis (OpenERP)

[FIX] ir.model.data: _update_dummy() must also mark _inherits objects as loaded to avoid deletion when a record pass from noupdate=0 to noupdate=1

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'openerp/addons/base/ir/ir_model.py'
--- openerp/addons/base/ir/ir_model.py 2013-04-24 09:34:03 +0000
+++ openerp/addons/base/ir/ir_model.py 2013-05-17 09:02:26 +0000
@@ -3,7 +3,7 @@
3##############################################################################3##############################################################################
4#4#
5# OpenERP, Open Source Business Applications5# OpenERP, Open Source Business Applications
6# Copyright (C) 2004-2012 OpenERP S.A. (<http://openerp.com>).6# Copyright (C) 2004-2013 OpenERP S.A. (<http://openerp.com>).
7#7#
8# This program is free software: you can redistribute it and/or modify8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU Affero General Public License as9# it under the terms of the GNU Affero General Public License as
@@ -879,15 +879,29 @@
879 raise ValueError('No record found for unique ID %s.%s. It may have been deleted.' % (module, xml_id))879 raise ValueError('No record found for unique ID %s.%s. It may have been deleted.' % (module, xml_id))
880 return result880 return result
881881
882 def _update_dummy(self,cr, uid, model, module, xml_id=False, store=True):882 def _mark_as_loaded(self, cr, uid, module, xml_id, model, res_id):
883 if not xml_id:883 if not xml_id:
884 return False884 return False
885 try:885 if not res_id:
886 id = self.read(cr, uid, [self._get_id(cr, uid, module, xml_id)], ['res_id'])[0]['res_id']886 try:
887 self.loads[(module,xml_id)] = (model,id)887 res_id = self.read(cr, uid, [self._get_id(cr, uid, module, xml_id)], ['res_id'])[0]['res_id']
888 except:888 except Exception:
889 id = False889 return False
890 return id890
891 self.loads[(module, xml_id)] = (model, res_id)
892 model_obj = self.pool[model]
893
894 f2t = dict((v, k) for k, v in model_obj._inherits.iteritems())
895 if f2t:
896 data = model_obj.read(cr, uid, res_id, f2t.keys())
897 for field, table in f2t.iteritems():
898 inherit_id = data[field]
899 self.loads[(module, xml_id + '_' + table.replace('.', '_'))] = (table, inherit_id)
900
901 return res_id
902
903 def _update_dummy(self, cr, uid, model, module, xml_id=False, store=True):
904 return self._mark_as_loaded(cr, uid, module, xml_id, model, res_id=False)
891905
892 def clear_caches(self):906 def clear_caches(self):
893 """ Clears all orm caches on the object's methods907 """ Clears all orm caches on the object's methods
@@ -981,11 +995,7 @@
981 'noupdate': noupdate,995 'noupdate': noupdate,
982 },context=context)996 },context=context)
983 if xml_id and res_id:997 if xml_id and res_id:
984 self.loads[(module, xml_id)] = (model, res_id)998 self._mark_as_loaded(cr, uid, module, xml_id, model, res_id)
985 for table, inherit_field in model_obj._inherits.iteritems():
986 inherit_id = model_obj.read(cr, uid, res_id,
987 [inherit_field])[inherit_field]
988 self.loads[(module, xml_id + '_' + table.replace('.', '_'))] = (table, inherit_id)
989 return res_id999 return res_id
9901000
991 def ir_set(self, cr, uid, key, key2, name, models, value, replace=True, isobject=False, meta=None, xml_id=False):1001 def ir_set(self, cr, uid, key, key2, name, models, value, replace=True, isobject=False, meta=None, xml_id=False):