From 6bb63edb98e0ad3244e2da54ae04c5f62aa69052 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Wed, 8 Mar 2017 15:15:42 +0100 Subject: [PATCH] [FIX] base: save ir.values - Install accounting module - Create new tax, keep note of its ID - Go to Settings > Technical > User-Defined Defaults - Change the value of 'taxes_id' to the ID of the tax created - Create a new product => crash The issue is that the value of 'taxes_id' is saved as a string, not as a list. Therefore, once retrieved, it crashes. opw-709906 --- odoo/addons/base/ir/ir_values.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/odoo/addons/base/ir/ir_values.py b/odoo/addons/base/ir/ir_values.py index 46d533b465b..3093851f5d2 100644 --- a/odoo/addons/base/ir/ir_values.py +++ b/odoo/addons/base/ir/ir_values.py @@ -1,6 +1,8 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. +from ast import literal_eval + from odoo import api, fields, models, tools, _ from odoo.exceptions import AccessError, MissingError from odoo.tools import pickle @@ -132,6 +134,12 @@ class IrValues(models.Model): context.pop(self.CONCURRENCY_CHECK_FIELD, None) for record in self.with_context(context): value = record.value_unpickle + # Only char-like fields should be written directly. Other types should be converted to + # their appropriate type first. + if record.model in self.env and record.name in self.env[record.model]._fields: + field = self.env[record.model]._fields[record.name] + if field.type not in ['char', 'text', 'html', 'selection']: + value = literal_eval(value) if record.key == 'default': value = pickle.dumps(value) record.value = value