Merge lp:~openerp-dev/openobject-server/5.0-opw-575229-cbi into lp:openobject-server/5.0

Proposed by Chris Biersbach (OpenERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-server/5.0-opw-575229-cbi
Merge into: lp:openobject-server/5.0
Diff against target: 29 lines (+7/-3)
1 file modified
bin/osv/orm.py (+7/-3)
To merge this branch: bzr merge lp:~openerp-dev/openobject-server/5.0-opw-575229-cbi
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+122239@code.launchpad.net

Description of the change

Bugfix: Changed copy_translations in orm.py to correctly pick the ID of the object correpsonding to an inherited field when copying the translations.
This bug is also present from 5.0 onwards

To reproduce the bug (in 5.0):

1) Install event module
2) Choose Belgium PCMN
3) Load an official translation: French
4) Change french translation of an event
5) Duplicate event
    -> Translation was not duplicated!

To post a comment you must log in.

Unmerged revisions

2182. By Chris Biersbach (OpenERP)

[FIX] OPW 575229: ORM: Fixed copy_translations to take ID of _inherits field instead of object ID

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/osv/orm.py'
2--- bin/osv/orm.py 2011-03-30 05:05:03 +0000
3+++ bin/osv/orm.py 2012-08-31 11:04:55 +0000
4@@ -3202,20 +3202,24 @@
5 # and for translatable fields we keep them for copy
6 elif field_def.get('translate'):
7 trans_name = ''
8+ old_id_to_copy, new_id_to_copy = old_id, new_id
9 if field_name in self._columns:
10 trans_name = self._name + "," + field_name
11 elif field_name in self._inherit_fields:
12 trans_name = self._inherit_fields[field_name][0] + "," + field_name
13+ parent_field = self._inherit_fields[field_name][1]
14+ old_parent_id, new_parent_id = self.read(cr, uid, [old_id, new_id], [parent_field])
15+ old_id_to_copy, new_id_to_copy = old_parent_id[parent_field][0], new_parent_id[parent_field][0]
16 if trans_name:
17 trans_ids = trans_obj.search(cr, uid, [
18 ('name', '=', trans_name),
19- ('res_id','=', old_id)
20+ ('res_id','=', old_id_to_copy)
21 ])
22- translation_records.extend(trans_obj.read(cr,uid,trans_ids,context=context))
23+ trans_records = trans_obj.read(cr,uid,trans_ids,context=context)
24+ translation_records.extend(dict(t, res_id=new_id_to_copy) for t in trans_records)
25
26 for record in translation_records:
27 del record['id']
28- record['res_id'] = new_id
29 trans_obj.create(cr, uid, record, context=context)
30
31