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

convert reference into uppercase

By
Thicham
on 4/13/15, 4:44 AM 662 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

1

Atchuthan - Technical Consultant, Sodexis Inc

--Atchuthan - Technical Consultant, Sodexis Inc--
3883
| 5 3 8
Puducherry, India
--Atchuthan - Technical Consultant, Sodexis Inc--
Passionate coder in Python/Odoo(formerly known as OpenERP).

Contact me via GMail: atchuthantu@gmail.com via Skype: atchuthan_skype
via Linkedin: http://in.linkedin.com/in/atchuthantu
Atchuthan - Technical Consultant, Sodexis Inc
On 4/13/15, 5:40 AM

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) 

0
Thicham
On 4/13/15, 10:48 AM

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

Product.Product

Atchuthan - Technical Consultant, Sodexis Inc
on 4/14/15, 10:52 AM
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

Thicham
on 4/14/15, 11:26 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

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

Question tools

2 follower(s)

Stats

Asked: 4/13/15, 4:44 AM
Seen: 662 times
Last updated: 4/15/15, 1:30 AM