Odoo Help


set Reference to uppercase automatically [Closed]

on 12/16/13, 7:06 AM 3,269 views

The Question has been closed

on 12/17/2013 07:49:48

Hi all, V6.1

I would like to set the Reference of every product to uppercase

i have this in my python code

_inherit = 'product.product'
_columns = {
    'quarantine': fields.date('Day Quarantined',required=False),
    'default_code': fields.char('Reference', size=80, select=True, required=True)
def onchange_case(self, cr, uid, ids, default_code):
    result = {'value': {
        'default_code': str(default_code).upper()
    return result

and this in xml

            <field name='default_code' on_change='onchange_case(default_code)'/>

it runs with no error but the default code (product Reference) is still not changing to upper cases any suggestions please. Thank you in advance all

The code is correct

on 12/17/13, 6:58 AM

The code is correct. It was the xml location that was wrong all along.

on 12/17/13, 7:49 AM
On 12/17/13, 6:25 AM

Solved this. I was very silly not to have replaced the default code with mine. I place the field after another of my custom fields rather than replace the old default code with mine. The code was working fine all the while since Monday. Just realized it when I changed xml code to

        <field name="default_code" position="replace">
            <field name="default_code" on_change="onchange_case(default_code)"/>

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

0 follower(s)


Asked: 12/16/13, 7:06 AM
Seen: 3269 times
Last updated: 3/16/15, 8:10 AM