Merge lp:~openerp-dev/openobject-server/trunk-bug-795444-xrg into lp:openobject-server

Proposed by xrg
Status: Work in progress
Proposed branch: lp:~openerp-dev/openobject-server/trunk-bug-795444-xrg
Merge into: lp:openobject-server
Diff against target: 225 lines (+48/-22)
5 files modified
openerp/addons/base/ir/ir_values.py (+3/-1)
openerp/addons/base/res/res_lang.py (+1/-1)
openerp/modules/loading.py (+3/-3)
openerp/tools/convert.py (+39/-15)
openerp/tools/yaml_import.py (+2/-2)
To merge this branch: bzr merge lp:~openerp-dev/openobject-server/trunk-bug-795444-xrg
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+64137@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Vo Minh Thu (thu) wrote :
Revision history for this message
Vo Minh Thu (thu) wrote :

Setting it to `Work in progress` as the related branch is in that state.

Unmerged revisions

3455. By OpenERP buildbot

addons/init: pass context to tools.convert_*

3454. By OpenERP buildbot

tools/convert,yaml_import: have context passed from caller

In the context, we will be able to distinguish if we are being called
in the module loading sequence or not

3453. By OpenERP buildbot

res.lang, ir.values: don't use ir.values as defaults when creating
(cherry picked from commit 7e419058ea3391e8b2e2bb45f8054dfb8af88e7b)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openerp/addons/base/ir/ir_values.py'
2--- openerp/addons/base/ir/ir_values.py 2011-05-25 15:17:22 +0000
3+++ openerp/addons/base/ir/ir_values.py 2011-06-10 09:47:26 +0000
4@@ -141,7 +141,9 @@
5 vals['company_id']=cid
6 if res_id:
7 vals['res_id']= res_id
8- ids_res.append(self.create(cr, uid, vals))
9+ # Note that __ignore_ir_values means vals will not be appended with a recursive
10+ # lookup using self.ir_get(, model='ir.values') !
11+ ids_res.append(self.create(cr, uid, vals, context={'__ignore_ir_values': True}))
12 return ids_res
13
14 def get(self, cr, uid, key, key2, models, meta=False, context=None, res_id_req=False, without_user=True, key2_req=True):
15
16=== modified file 'openerp/addons/base/res/res_lang.py'
17--- openerp/addons/base/res/res_lang.py 2011-06-03 08:57:58 +0000
18+++ openerp/addons/base/res/res_lang.py 2011-06-10 09:47:26 +0000
19@@ -109,7 +109,7 @@
20 }
21 lang_id = False
22 try:
23- lang_id = self.create(cr, uid, lang_info)
24+ lang_id = self.create(cr, uid, lang_info, context={'__ignore_ir_values':True})
25 finally:
26 tools.resetlocale()
27 return lang_id
28
29=== modified file 'openerp/modules/loading.py'
30--- openerp/modules/loading.py 2011-05-17 09:18:22 +0000
31+++ openerp/modules/loading.py 2011-06-10 09:47:26 +0000
32@@ -138,13 +138,13 @@
33 if ext == '.csv':
34 if kind in ('init', 'init_xml'):
35 noupdate = True
36- tools.convert_csv_import(cr, module_name, pathname, fp.read(), idref, mode, noupdate)
37+ tools.convert_csv_import(cr, module_name, pathname, fp.read(), idref, mode, noupdate, context={ '__ignore_ir_values': True })
38 elif ext == '.sql':
39 process_sql_file(cr, fp)
40 elif ext == '.yml':
41- tools.convert_yaml_import(cr, module_name, fp, idref, mode, noupdate)
42+ tools.convert_yaml_import(cr, module_name, fp, idref, mode, noupdate, context={ '__ignore_ir_values': True })
43 else:
44- tools.convert_xml_import(cr, module_name, fp, idref, mode, noupdate, report)
45+ tools.convert_xml_import(cr, module_name, fp, idref, mode, noupdate, report, context={ '__ignore_ir_values': True })
46 finally:
47 fp.close()
48
49
50=== modified file 'openerp/tools/convert.py'
51--- openerp/tools/convert.py 2011-05-16 15:05:34 +0000
52+++ openerp/tools/convert.py 2011-06-10 09:47:26 +0000
53@@ -347,7 +347,10 @@
54 groups_value.append((4, group_id))
55 res['groups_id'] = groups_value
56
57- id = self.pool.get('ir.model.data')._update(cr, self.uid, "ir.actions.report.xml", self.module, res, xml_id, noupdate=self.isnoupdate(data_node), mode=self.mode)
58+ id = self.pool.get('ir.model.data')._update(cr, self.uid,
59+ "ir.actions.report.xml", self.module, res, xml_id,
60+ noupdate=self.isnoupdate(data_node), mode=self.mode,
61+ context=self.context)
62 self.idref[xml_id] = int(id)
63
64 if not rec.get('menu') or eval(rec.get('menu','False')):
65@@ -390,7 +393,10 @@
66 groups_value.append((4, group_id))
67 res['groups_id'] = groups_value
68
69- id = self.pool.get('ir.model.data')._update(cr, self.uid, "ir.actions.wizard", self.module, res, xml_id, noupdate=self.isnoupdate(data_node), mode=self.mode)
70+ id = self.pool.get('ir.model.data')._update(cr, self.uid,
71+ "ir.actions.wizard", self.module, res, xml_id,
72+ noupdate=self.isnoupdate(data_node), mode=self.mode,
73+ context=self.context)
74 self.idref[xml_id] = int(id)
75 # ir_set
76 if (not rec.get('menu') or eval(rec.get('menu','False'))) and id:
77@@ -412,14 +418,19 @@
78
79 res = {'name': name, 'url': url, 'target':target}
80
81- id = self.pool.get('ir.model.data')._update(cr, self.uid, "ir.actions.url", self.module, res, xml_id, noupdate=self.isnoupdate(data_node), mode=self.mode)
82+ id = self.pool.get('ir.model.data')._update(cr, self.uid,
83+ "ir.actions.url", self.module, res, xml_id,
84+ noupdate=self.isnoupdate(data_node), mode=self.mode,
85+ context=self.context)
86 self.idref[xml_id] = int(id)
87 # ir_set
88 if (not rec.get('menu') or eval(rec.get('menu','False'))) and id:
89 keyword = str(rec.get('keyword','') or 'client_action_multi')
90 value = 'ir.actions.url,'+str(id)
91 replace = rec.get("replace",'') or True
92- self.pool.get('ir.model.data').ir_set(cr, self.uid, 'action', keyword, url, ["ir.actions.url"], value, replace=replace, isobject=True, xml_id=xml_id)
93+ self.pool.get('ir.model.data').ir_set(cr, self.uid,
94+ 'action', keyword, url, ["ir.actions.url"], value,
95+ replace=replace, isobject=True, xml_id=xml_id)
96 elif self.mode=='update' and (rec.get('menu') and eval(rec.get('menu','False'))==False):
97 # Special check for URL having attribute menu=False on update
98 value = 'ir.actions.url,'+str(id)
99@@ -522,7 +533,10 @@
100 res['target'] = rec.get('target','')
101 if rec.get('multi'):
102 res['multi'] = rec.get('multi', False)
103- id = self.pool.get('ir.model.data')._update(cr, self.uid, 'ir.actions.act_window', self.module, res, xml_id, noupdate=self.isnoupdate(data_node), mode=self.mode)
104+ id = self.pool.get('ir.model.data')._update(cr, self.uid,
105+ 'ir.actions.act_window', self.module, res, xml_id,
106+ noupdate=self.isnoupdate(data_node), mode=self.mode,
107+ context=self.context)
108 self.idref[xml_id] = int(id)
109
110 if src_model:
111@@ -679,7 +693,11 @@
112
113 xml_id = rec.get('id','').encode('utf8')
114 self._test_xml_id(xml_id)
115- pid = self.pool.get('ir.model.data')._update(cr, self.uid, 'ir.ui.menu', self.module, values, xml_id, noupdate=self.isnoupdate(data_node), mode=self.mode, res_id=res and res[0] or False)
116+ pid = self.pool.get('ir.model.data')._update(cr, self.uid,
117+ 'ir.ui.menu', self.module, values, xml_id,
118+ noupdate=self.isnoupdate(data_node), mode=self.mode,
119+ res_id=res and res[0] or False,
120+ context=self.context)
121
122 if rec_id and pid:
123 self.idref[rec_id] = int(pid)
124@@ -774,9 +792,9 @@
125 model = self.pool.get(rec_model)
126 assert model, "The model %s does not exist !" % (rec_model,)
127 rec_id = rec.get("id",'').encode('ascii')
128- rec_context = rec.get("context", None)
129- if rec_context:
130- rec_context = unsafe_eval(rec_context)
131+ rec_context = self.context.copy()
132+ if rec.get("context", None):
133+ rec_context.update(unsafe_eval(rec.get('context')))
134 self._test_xml_id(rec_id)
135 if self.isnoupdate(data_node) and self.mode != 'init':
136 # check if the xml record has an id string
137@@ -849,7 +867,11 @@
138 f_val = int(f_val)
139 res[f_name] = f_val
140
141- id = self.pool.get('ir.model.data')._update(cr, self.uid, rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode, context=rec_context )
142+ id = self.pool.get('ir.model.data')._update(cr, self.uid,
143+ rec_model, self.module, res, rec_id or False,
144+ not self.isnoupdate(data_node),
145+ noupdate=self.isnoupdate(data_node),
146+ mode=self.mode, context=rec_context )
147 if rec_id:
148 self.idref[rec_id] = int(id)
149 if config.get('import_partial', False):
150@@ -892,7 +914,7 @@
151 raise
152 return True
153
154- def __init__(self, cr, module, idref, mode, report=None, noupdate=False):
155+ def __init__(self, cr, module, idref, mode, report=None, noupdate=False, context=None):
156
157 self.logger = logging.getLogger('init')
158 self.mode = mode
159@@ -905,6 +927,7 @@
160 report = assertion_report()
161 self.assert_report = report
162 self.noupdate = noupdate
163+ self.context = context or {}
164 self._tags = {
165 'menuitem': self._tag_menuitem,
166 'record': self._tag_record,
167@@ -920,7 +943,7 @@
168 }
169
170 def convert_csv_import(cr, module, fname, csvcontent, idref=None, mode='init',
171- noupdate=False):
172+ noupdate=False, context=None):
173 '''Import csv file :
174 quote: "
175 delimiter: ,
176@@ -964,7 +987,8 @@
177 datas.append(map(lambda x: misc.ustr(x), line))
178 except:
179 logger.error("Cannot import the line: %s", line)
180- result, rows, warning_msg, dummy = pool.get(model).import_data(cr, uid, fields, datas,mode, module, noupdate, filename=fname_partial)
181+ result, rows, warning_msg, dummy = pool.get(model).import_data(cr, uid,
182+ fields, datas,mode, module, noupdate, filename=fname_partial, context=context)
183 if result < 0:
184 # Report failed import and abort module install
185 raise Exception(_('Module loading failed: file %s/%s could not be processed:\n %s') % (module, fname, warning_msg))
186@@ -977,7 +1001,7 @@
187 #
188 # xml import/export
189 #
190-def convert_xml_import(cr, module, xmlfile, idref=None, mode='init', noupdate=False, report=None):
191+def convert_xml_import(cr, module, xmlfile, idref=None, mode='init', noupdate=False, report=None, context=None):
192 doc = etree.parse(xmlfile)
193 relaxng = etree.RelaxNG(
194 etree.parse(os.path.join(config['root_path'],'import_xml.rng' )))
195@@ -991,7 +1015,7 @@
196
197 if idref is None:
198 idref={}
199- obj = xml_import(cr, module, idref, mode, report=report, noupdate=noupdate)
200+ obj = xml_import(cr, module, idref, mode, report=report, noupdate=noupdate, context=context)
201 obj.parse(doc.getroot())
202 return True
203
204
205=== modified file 'openerp/tools/yaml_import.py'
206--- openerp/tools/yaml_import.py 2011-06-05 13:51:16 +0000
207+++ openerp/tools/yaml_import.py 2011-06-10 09:47:26 +0000
208@@ -132,7 +132,7 @@
209 self.logger = logging.getLogger("%s.%s" % (logger_channel, self.module))
210 self.pool = pooler.get_pool(cr.dbname)
211 self.uid = 1
212- self.context = {} # opererp context
213+ self.context = kwargs.get('context', {})
214 self.eval_context = {'ref': self._ref(),
215 '_ref': self._ref(), # added '_ref' so that record['ref'] is possible
216 'time': time,
217@@ -792,7 +792,7 @@
218 is_preceded_by_comment = False
219 return is_preceded_by_comment
220
221-def yaml_import(cr, module, yamlfile, idref=None, mode='init', noupdate=False):
222+def yaml_import(cr, module, yamlfile, idref=None, mode='init', noupdate=False, context=None):
223 if idref is None:
224 idref = {}
225 yaml_string = yamlfile.read()