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

Proposed by Chris Biersbach (OpenERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-server/6.0-opw-575229-cbi
Merge into: lp:openobject-server/6.0
Diff against target: 29 lines (+7/-4)
1 file modified
bin/osv/orm.py (+7/-4)
To merge this branch: bzr merge lp:~openerp-dev/openobject-server/6.0-opw-575229-cbi
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+122238@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

3636. By Chris Biersbach (OpenERP)

[FIX] OPW 575229: ORM: Fixed copy_translations to take ID of _inherits field instead of object ID (forward-port of 5.0 fix)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bin/osv/orm.py'
--- bin/osv/orm.py 2012-06-19 08:29:38 +0000
+++ bin/osv/orm.py 2012-08-31 11:03:05 +0000
@@ -4202,20 +4202,23 @@
4202 # and for translatable fields we keep them for copy4202 # and for translatable fields we keep them for copy
4203 elif field_def.get('translate'):4203 elif field_def.get('translate'):
4204 trans_name = ''4204 trans_name = ''
4205 old_id_to_copy, new_id_to_copy = old_id, new_id
4205 if field_name in self._columns:4206 if field_name in self._columns:
4206 trans_name = self._name + "," + field_name4207 trans_name = self._name + "," + field_name
4207 elif field_name in self._inherit_fields:4208 elif field_name in self._inherit_fields:
4208 trans_name = self._inherit_fields[field_name][0] + "," + field_name4209 trans_name = self._inherit_fields[field_name][0] + "," + field_name
4210 parent_field = self._inherit_fields[field_name][1]
4211 old_parent_id, new_parent_id = self.read(cr, uid, [old_id, new_id], [parent_field])
4212 old_id_to_copy, new_id_to_copy = old_parent_id[parent_field][0], new_parent_id[parent_field][0]
4209 if trans_name:4213 if trans_name:
4210 trans_ids = trans_obj.search(cr, uid, [4214 trans_ids = trans_obj.search(cr, uid, [
4211 ('name', '=', trans_name),4215 ('name', '=', trans_name),
4212 ('res_id', '=', old_id)4216 ('res_id','=', old_id_to_copy) ])
4213 ])4217 trans_records = trans_obj.read(cr,uid,trans_ids,context=context)
4214 translation_records.extend(trans_obj.read(cr, uid, trans_ids, context=context))4218 translation_records.extend(dict(t, res_id=new_id_to_copy) for t in trans_records)
42154219
4216 for record in translation_records:4220 for record in translation_records:
4217 del record['id']4221 del record['id']
4218 record['res_id'] = new_id
4219 trans_obj.create(cr, uid, record, context=context)4222 trans_obj.create(cr, uid, record, context=context)
42204223
42214224