Odoo Help


5 Answers

Techno-Functional Associate with 7+ years of experience in Odoo (formerly known as OpenERP).

6/17/16, 7:00 AM

I guess the column "internal reference" which you have added is either a related or computation field, which is not saved to database, if yes then sorting will not happen.

Sorting is a property availed from database, hence you can perform sorting action only on those columns which are actually present/stored into the database.

By default all the basic data-type columns (such as Char, Float etc) will be physically created into the table except for related & computation fields, for which one need to store it explicitly into the database by adding the property "store=True" against the field in PyObject/Class.

Disgal Milladoiro, S.L., Roberto Barreiro
6/17/16, 9:55 AM

The field named "internal reference" it's stored on database, on the table "product_product". On the interface of odoo, the label of this field is "internal reference", but at database the name it's "default_code". The type of the field is "character varying". Thank you.

Disgal Milladoiro, S.L., Roberto Barreiro
6/17/16, 12:10 PM

Server restarted and your solution works! Thank you very much!

Roberto Barreiro
6/17/16, 12:12 PM

You are right, now I saw the field default_code on the product_template model, it's a related field to the product_product model. As you said, solved with parameter store=True.

class product_template(osv.osv):

_inherit = 'product.template'

_columns = {

'default_code': fields.related('product_variant_ids', 'default_code', type='char', string='Internal Reference', store=True),


5/8/17, 11:28 AM

I am new to this. Could I have the steps to where I can place the above code in odoo?

Disgal Milladoiro, S.L., Roberto Barreiro
5/8/17, 11:45 AM

The code it's placed on a customized module. Take a look at this addon, this code belongs to it:


5/8/17, 12:11 PM

Thank you very much for sharing this module. It is exactly what is needed. This module will help us save much time. Thank you again for sharing the module.

Ask a Question
Keep Informed
2 follower(s)
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 eLearning platform and experience all Odoo Apps through learning videos, use cases and quizzes.

Test it now