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

Proposed by Ronald Portier (Therp)
Status: Rejected
Rejected by: Holger Brunn (Therp)
Proposed branch: lp:~therp-nl/ocb-server/7.0_lp1321675_crash_on_copy
Merge into: lp:ocb-server
Diff against target: 31 lines (+14/-7)
1 file modified
openerp/osv/orm.py (+14/-7)
To merge this branch: bzr merge lp:~therp-nl/ocb-server/7.0_lp1321675_crash_on_copy
Reviewer Review Type Date Requested Status
Holger Brunn (Therp) Disapprove
Review via email: mp+220427@code.launchpad.net

Description of the change

Fix lp1321675. Exception when copying record with one2many function field.

To post a comment you must log in.
Revision history for this message
Holger Brunn (Therp) (hbrunn) wrote :

Development for 7.0 has moved to github on https://github.com/OCA/ocb - please move your merge proposal there if it is still valid.

(I close and reject this in order to have a cleaner overview for 6.1 MPs which indeed have to be done on launchpad)

review: Disapprove

Unmerged revisions

5338. By Ronald Portier (Therp)

[FIX] Do not copy translations for not stored function fields.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'openerp/osv/orm.py'
--- openerp/osv/orm.py 2014-05-19 16:12:41 +0000
+++ openerp/osv/orm.py 2014-05-21 10:42:58 +0000
@@ -5067,13 +5067,20 @@
5067 old_record, new_record = self.browse(cr, uid, [old_id, new_id], context=context_wo_lang)5067 old_record, new_record = self.browse(cr, uid, [old_id, new_id], context=context_wo_lang)
5068 # we must recursively copy the translations for o2o and o2m5068 # we must recursively copy the translations for o2o and o2m
5069 if field_def['type'] == 'one2many':5069 if field_def['type'] == 'one2many':
5070 target_obj = self.pool.get(field_def['relation'])5070 # do not copy function fields, unless they are stored:
5071 # here we rely on the order of the ids to match the translations5071 if ((not 'function' in field_def)
5072 # as foreseen in copy_data()5072 or ('store' in field_def and field_def['store'])):
5073 old_children = sorted(r.id for r in old_record[field_name])5073 target_obj = self.pool.get(field_def['relation'])
5074 new_children = sorted(r.id for r in new_record[field_name])5074 # here we rely on the order of the ids to match the
5075 for (old_child, new_child) in zip(old_children, new_children):5075 # translations as foreseen in copy_data()
5076 target_obj.copy_translations(cr, uid, old_child, new_child, context=context)5076 old_children = sorted(
5077 r.id for r in old_record[field_name])
5078 new_children = sorted(
5079 r.id for r in new_record[field_name])
5080 for (old_child, new_child) in zip(
5081 old_children, new_children):
5082 target_obj.copy_translations(
5083 cr, uid, old_child, new_child, context=context)
5077 # and for translatable fields we keep them for copy5084 # and for translatable fields we keep them for copy
5078 elif field_def.get('translate'):5085 elif field_def.get('translate'):
5079 if field_name in self._columns:5086 if field_name in self._columns:

Subscribers

People subscribed via source and target branches

to status/vote changes: