This question has been flagged
2 Replies
5023 Views

How to save the reference of every product as uppercase (when click on the "save" button)

please some help in both xml code and python code !

thank you

Avatar
Discard
Best Answer

overwrite WRITE method and change the value passed through it as UPPERCASE conversion.

from openerp import models, api
class Product(models.Model):
    _inherit = 'product.product'

    @api.model
    def create(self, vals):
        if vals.get('default_code', False):
            vals['default_code'] = vals.get('default_code', '').upper()
        return super(Product, self).create(vals)

    @api.multi
    def write(self, vals):
        if vals.get('default_code', False):
            vals['default_code'] = vals.get('default_code', '').upper()
        return super(Product, self).write(vals)


To resolve old data, do an one time sql query
update product_product set default_code=UPPER(default_code) 

Avatar
Discard
Author Best Answer

Please, inside which class (product.product or product.template) should i insert the method ?

Avatar
Discard
Actually, i created a new module and inherited the product form view in wich i added the reference field.
now it shows FALSE instead of being empty :p !!!

__________________
Hicham TAROQ
Élève Ingénieur à l'Institut National des Postes et Télécommunications-INPT Rabat



On Tue, Apr 14, 2015 at 3:52 PM, Atchuthan - Technical Consultant, Sodexis Inc <atchuthantu-gmail.com@mail.odoo.com> wrote:

Product.Product

--
Atchuthan - Technical Consultant, Sodexis Inc
Sent by Odoo Inc. using Odoo access your messages