Merge lp:~therp-nl/ocb-server/7.0-lp1194893-export_xmlid_wrong_table_name into lp:ocb-server

Proposed by Stefan Rijnhart (Opener)
Status: Merged
Merged at revision: 5043
Proposed branch: lp:~therp-nl/ocb-server/7.0-lp1194893-export_xmlid_wrong_table_name
Merge into: lp:ocb-server
Diff against target: 28 lines (+3/-3)
1 file modified
openerp/osv/orm.py (+3/-3)
To merge this branch: bzr merge lp:~therp-nl/ocb-server/7.0-lp1194893-export_xmlid_wrong_table_name
Reviewer Review Type Date Requested Status
Holger Brunn (Therp) code review Approve
Nicolas Bessi - Camptocamp (community) no test code review only Approve
Review via email: mp+171567@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Before you ask, line 9 is unintentional. Since r._table_name is in fact equivalent to r._model._name, it does not constitute a functional change. But I would like to leave it there to resolve the confusion that made me put it there in the first place.

Revision history for this message
Nicolas Bessi - Camptocamp (nbessi-c2c-deactivatedaccount) wrote :

Hello,
Thanks for the MP.

line 18 is there a reason why use use _model._table instead of _model._name ?
It also appear that _table is deprecated:

        self._table = table # deprecated, use _model!

We may also fix spacing, or are you afraid of merge conflict?

Regards

Nicolas

review: Needs Information (no test, code review)
Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Why use table and not model name? This MP does not change anything about that, but I am guessing that the reason is that XML-IDs are not supposed to have more than one dot. Having XML-IDs like '__export__.res.partner_169' could be confusing.

Using browse_record._table is deprecated, that is why I am using browse_record._model. Using Model._table is not deprecated ;-)

Revision history for this message
Nicolas Bessi - Camptocamp (nbessi-c2c-deactivatedaccount) wrote :

Ok then LGTM

review: Approve (no test code review only)
Revision history for this message
Holger Brunn (Therp) (hbrunn) :
review: Approve (code review)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openerp/osv/orm.py'
2--- openerp/osv/orm.py 2013-06-20 13:10:57 +0000
3+++ openerp/osv/orm.py 2013-06-26 14:16:36 +0000
4@@ -1106,7 +1106,7 @@
5
6 def _get_xml_id(self, cr, uid, r):
7 model_data = self.pool.get('ir.model.data')
8- data_ids = model_data.search(cr, uid, [('model', '=', r._table_name), ('res_id', '=', r['id'])])
9+ data_ids = model_data.search(cr, uid, [('model', '=', r._model._name), ('res_id', '=', r['id'])])
10 if len(data_ids):
11 d = model_data.read(cr, uid, data_ids, ['name', 'module'])[0]
12 if d['module']:
13@@ -1116,13 +1116,13 @@
14 else:
15 postfix = 0
16 while True:
17- n = self._table+'_'+str(r['id']) + (postfix and ('_'+str(postfix)) or '' )
18+ n = r._model._table+'_'+str(r['id']) + (postfix and ('_'+str(postfix)) or '' )
19 if not model_data.search(cr, uid, [('name', '=', n)]):
20 break
21 postfix += 1
22 model_data.create(cr, SUPERUSER_ID, {
23 'name': n,
24- 'model': self._name,
25+ 'model': r._model._name,
26 'res_id': r['id'],
27 'module': '__export__',
28 })

Subscribers

People subscribed via source and target branches

to status/vote changes: