Merge lp:~openerp-dev/openobject-server/7.0-opw-607398-rgo into lp:openobject-server/7.0

Proposed by Ravi Gohil (OpenERP)
Status: Merged
Merged at revision: 5295
Proposed branch: lp:~openerp-dev/openobject-server/7.0-opw-607398-rgo
Merge into: lp:openobject-server/7.0
Diff against target: 23 lines (+5/-1)
1 file modified
openerp/addons/base/ir/ir_values.py (+5/-1)
To merge this branch: bzr merge lp:~openerp-dev/openobject-server/7.0-opw-607398-rgo
Reviewer Review Type Date Requested Status
Martin Trigaux (OpenERP) (community) Approve
Review via email: mp+218276@code.launchpad.net

Description of the change

Steps to reproduce issue:
- Install account module,
- Go to "Settings/Configuration/Invoicing" and set "Default Sale Tax"(this tax will be used as default for many2many field "Customer Taxes" when creating a new product),
- Now, go to "Settings/Actions/User-defined Defaults" and change the default value(value in form of the list) for 'taxes_id'("Customer Taxes"),
- Try to create a new product and a same error will be faced as mentioned in lp:1153628,

The cause of the issue is that with each write call to the functional field "value_unpickle", it always dump a string object for a list value(rather then dumping it as a list object) to the field "value".

Wrong value will be dumped for all the fields other than char/selection/text type fields.

This branch fixes this, kindly review it.

Thanks.

To post a comment you must log in.
5295. By Ravi Gohil (OpenERP)

[FIX] Modifying default value for other than char/string/selection fields from 'Setting/Technical/Actions/User-defined Defaults' view sets wrong pickle value for respective record. (Maintenance Case: 607398)

Revision history for this message
Martin Trigaux (OpenERP) (mat-openerp) wrote :

Merged in 7.0, thanks

revno: 5295 [merge]
revision-id: <email address hidden>

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openerp/addons/base/ir/ir_values.py'
2--- openerp/addons/base/ir/ir_values.py 2013-06-07 09:02:51 +0000
3+++ openerp/addons/base/ir/ir_values.py 2014-05-06 06:52:37 +0000
4@@ -22,6 +22,7 @@
5
6 from openerp.osv import osv, fields
7 from openerp.osv.orm import except_orm
8+from openerp.tools.safe_eval import safe_eval as eval
9
10 EXCLUDED_FIELDS = set((
11 'report_sxw_content', 'report_rml_content', 'report_sxw', 'report_rml',
12@@ -121,7 +122,10 @@
13 record = self.browse(cursor, user, id, context=context)
14 if record.key == 'default':
15 # default values are pickled on the fly
16- value = pickle.dumps(value)
17+ try:
18+ value = isinstance(value, (str, unicode)) and pickle.dumps(eval(value)) or pickle.dumps(value)
19+ except Exception:
20+ value = pickle.dumps(value)
21 self.write(cursor, user, id, {name[:-9]: value}, context=ctx)
22
23 def onchange_object_id(self, cr, uid, ids, object_id, context=None):