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
1=== modified file 'openerp/osv/orm.py'
2--- openerp/osv/orm.py 2014-05-19 16:12:41 +0000
3+++ openerp/osv/orm.py 2014-05-21 10:42:58 +0000
4@@ -5067,13 +5067,20 @@
5 old_record, new_record = self.browse(cr, uid, [old_id, new_id], context=context_wo_lang)
6 # we must recursively copy the translations for o2o and o2m
7 if field_def['type'] == 'one2many':
8- target_obj = self.pool.get(field_def['relation'])
9- # here we rely on the order of the ids to match the translations
10- # as foreseen in copy_data()
11- old_children = sorted(r.id for r in old_record[field_name])
12- new_children = sorted(r.id for r in new_record[field_name])
13- for (old_child, new_child) in zip(old_children, new_children):
14- target_obj.copy_translations(cr, uid, old_child, new_child, context=context)
15+ # do not copy function fields, unless they are stored:
16+ if ((not 'function' in field_def)
17+ or ('store' in field_def and field_def['store'])):
18+ target_obj = self.pool.get(field_def['relation'])
19+ # here we rely on the order of the ids to match the
20+ # translations as foreseen in copy_data()
21+ old_children = sorted(
22+ r.id for r in old_record[field_name])
23+ new_children = sorted(
24+ r.id for r in new_record[field_name])
25+ for (old_child, new_child) in zip(
26+ old_children, new_children):
27+ target_obj.copy_translations(
28+ cr, uid, old_child, new_child, context=context)
29 # and for translatable fields we keep them for copy
30 elif field_def.get('translate'):
31 if field_name in self._columns:

Subscribers

People subscribed via source and target branches

to status/vote changes: