Odoo Help


How to remove the extra quotes of selections options?

on 4/23/15, 11:32 PM 1,419 views

I have selection fields defined as below, but the output have extra quotes in option values which will raise ValueError("Wrong value for %s: %r" % (self, value)) when selecting. Anyone knows how to remove those extra quotes? Thanks!


_columns = {
        'name' : fields.char('Name', compute='_compute_name', required=1, store=1, default=''),
        'x_material': fields.selection([
            ('ASTM A105','ASTM A105'),
            ('ASTM A350 LF2 CL1','ASTM A350 LF2 CL1'),
            ('ASTM A182 F304','ASTM A182 F304'),
            ('ASTM A182 F304L','ASTM A182 F304L'),
            ('ASTM A182 F316','ASTM A182 F316'),
            ('ASTM A182 F316L','ASTM A182 F316L')
            ],'Mateirial', required=0),
        'x_surface_condition': fields.selection([
            ('finished','Finished Product')
            ], 'Surface Condition', required=0),        
        'x_heat_number': fields.char(string='Heat Number', required=0),
        'x_standard': fields.selection(selection=[], string='Standards', required=1),
        'x_pressure': fields.selection(selection=[], string='Pressure', required=1),
        'x_type': fields.selection(selection=[], string='Type', required=1),
        'x_facing': fields.selection(selection=[], string='Facing', required=1),
        'x_size': fields.selection(selection=[], string='Size (mm)', required=1),
        'x_weight': fields.selection(selection=[], string='Unit Weight (kg)', required=1),
        'x_wall_thickness': fields.selection(selection=[], string='Wall Thickness', required=0),
        'x_long': fields.selection(selection=[], string='Height (mm)', required=0),
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):         
        if context is None:context = {} res = super(product_flange, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar,submenu=False) for field in res['fields']: if field in ['x_standard','x_pressure','x_type','x_facing','x_size']: cr.execute("SELECT DISTINCT "+field+" FROM product_ftype WHERE "+field+" <> '' ORDER BY "+field+" ASC") res['fields'][field]['selection'] = [(r[0], r[0]) for r in cr.fetchall()] return res.


<select id="oe-field-input-5" name="x_standard">
                <option value="false"></option>
                <option value=""ASME B16.47-A"">ASME B16.47-A</option>
                <option value=""ASME B16.47-B"">ASME B16.47-B</option>
                <option value=""ASME B16.5"">ASME B16.5</option>
                <option value=""EN1092-1"">EN1092-1</option>

Double quotes seems like intended behavior and can also be seen on selection fields of core modules. Can you post the whole stack trace for that error?

Jaakko Komulainen
on 4/24/15, 6:55 AM

Here it is~ Odoo Server Error Traceback (most recent call last): File "E:\work\flangewarehouse.com\odoo\openerp\http.py", line 530, in _handle_exception return super(JsonRequest, self)._handle_exception(exception) File "E:\work\flangewarehouse.com\odoo\openerp\http.py", line 567, in dispatch result = self._call_function(**self.params) File "E:\work\flangewarehouse.com\odoo\openerp\http.py", line 303, in _call_function return checked_call(self.db, *args, **kwargs) File "E:\work\flangewarehouse.com\odoo\openerp\service\model.py", line 113, in wrapper return f(dbname, *args, **kwargs) File "E:\work\flangewarehouse.com\odoo\openerp\http.py", line 300, in checked_call return self.endpoint(*a, **kw) File "E:\work\flangewarehouse.com\odoo\openerp\http.py", line 796, in __call__ return self.method(*args, **kw) File "E:\work\flangewarehouse.com\odoo\openerp\http.py", line 396, in response_wrap response = f(*args, **kw) File "E:\work\flangewarehouse.com\odoo\openerp\addons\web\controllers\main.py", line 949, in call_kw return self._call_kw(model, method, args, kwargs) File "E:\work\flangewarehouse.com\odoo\openerp\addons\web\controllers\main.py", line 941, in _call_kw return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs) File "E:\work\flangewarehouse.com\odoo\openerp\api.py", line 241, in wrapper return old_api(self, *args, **kwargs) File "E:\work\flangewarehouse.com\odoo\openerp\api.py", line 363, in old_api result = method(recs, *args, **kwargs) File "E:\work\flangewarehouse.com\odoo\openerp\models.py", line 5775, in onchange record = self.new(values) File "E:\work\flangewarehouse.com\odoo\openerp\api.py", line 239, in wrapper return new_api(self, *args, **kwargs) File "E:\work\flangewarehouse.com\odoo\openerp\models.py", line 5368, in new record._cache.update(record._convert_to_cache(values, update=True)) File "E:\work\flangewarehouse.com\odoo\openerp\models.py", line 5267, in _convert_to_cache for name, value in values.iteritems() File "E:\work\flangewarehouse.com\odoo\openerp\models.py", line 5268, in if name in fields File "E:\work\flangewarehouse.com\odoo\openerp\fields.py", line 1323, in convert_to_cache raise ValueError("Wrong value for %s: %r" % (self, value)) ValueError: Wrong value for product.flange.x_standard: 'ASME B16.47-A'

on 4/24/15, 10:51 PM
On 5/4/15, 5:57 AM

This is a late reply but i guess it might be useful for other.

This is a problem cause by unicode so to resolve it, just tell the system that you are using unicode text in selection field by using 'u'. Here is the example :

_columns = {        
'selection_field':fields.selection([(u'សំរាប់ក្រសួង', u'សំរាប់ក្រសួង'),(u'សំរាប់និស្សិត', u'សំរាប់និស្សិត')], 'Template Type')

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 4/23/15, 11:32 PM
Seen: 1419 times
Last updated: 5/4/15, 5:57 AM