openerp-community-reviewer team mailing list archive
-
openerp-community-reviewer team
-
Mailing list archive
-
Message #06908
[Merge] lp:~therp-nl/ocb-server/7.0_lp1321675_crash_on_copy into lp:ocb-server
Ronald Portier (Therp) has proposed merging lp:~therp-nl/ocb-server/7.0_lp1321675_crash_on_copy into lp:ocb-server.
Requested reviews:
OpenERP Community Backports (ocb)
Related bugs:
Bug #1321675 in OpenERP Community Backports (Server): "Server crash when copying one2many function field"
https://bugs.launchpad.net/ocb-server/+bug/1321675
For more details, see:
https://code.launchpad.net/~therp-nl/ocb-server/7.0_lp1321675_crash_on_copy/+merge/220427
Fix lp1321675. Exception when copying record with one2many function field.
--
https://code.launchpad.net/~therp-nl/ocb-server/7.0_lp1321675_crash_on_copy/+merge/220427
Your team OpenERP Community Backports is requested to review the proposed merge of lp:~therp-nl/ocb-server/7.0_lp1321675_crash_on_copy into lp:ocb-server.
=== 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 @@
old_record, new_record = self.browse(cr, uid, [old_id, new_id], context=context_wo_lang)
# we must recursively copy the translations for o2o and o2m
if field_def['type'] == 'one2many':
- target_obj = self.pool.get(field_def['relation'])
- # here we rely on the order of the ids to match the translations
- # as foreseen in copy_data()
- old_children = sorted(r.id for r in old_record[field_name])
- new_children = sorted(r.id for r in new_record[field_name])
- for (old_child, new_child) in zip(old_children, new_children):
- target_obj.copy_translations(cr, uid, old_child, new_child, context=context)
+ # do not copy function fields, unless they are stored:
+ if ((not 'function' in field_def)
+ or ('store' in field_def and field_def['store'])):
+ target_obj = self.pool.get(field_def['relation'])
+ # here we rely on the order of the ids to match the
+ # translations as foreseen in copy_data()
+ old_children = sorted(
+ r.id for r in old_record[field_name])
+ new_children = sorted(
+ r.id for r in new_record[field_name])
+ for (old_child, new_child) in zip(
+ old_children, new_children):
+ target_obj.copy_translations(
+ cr, uid, old_child, new_child, context=context)
# and for translatable fields we keep them for copy
elif field_def.get('translate'):
if field_name in self._columns:
Follow ups