Odoo Help

Welcome!

This community 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.

0

set Reference to uppercase automatically [Closed]

By
kaynis
on 12/16/13, 7:06 AM 1,997 views

The Question has been closed

by
kaynis
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

Soohoo
on 12/17/13, 6:58 AM

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

kaynis
on 12/17/13, 7:49 AM
0
kaynis
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)"/>
        </field>

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

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