Odoo Help


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.


How to change the default sorting of projects by "End Date"

Yoshi Tashiro
on 7/6/13, 11:18 PM 2,630 views

Must be some basic stuff, but I would like to know how I can sort projects by End Date. I have tried below in an addon module...

from openerp.osv import fields, osv
class project(osv.osv):
    _inherit = 'project.project'
    _name = 'project.project'
    _order = 'date'

And I get this error.

ProgrammingError: column "date" does not exist
LINE 1: ...0, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63) ORDER BY date

I realize that the original project class _inherits "account.analytic.account" which is where the End Date comes from. In such case how can we use a field that belong to the original model in sorting?


Ghanshyam Prajapati

--Ghanshyam Prajapati--
| 4 4 8
Pune, India
--Ghanshyam Prajapati--
OpenERP Developer
Ghanshyam Prajapati
On 7/7/13, 5:27 AM

Hello, I found the solution, here in project object , it inherits account.analytic.account object. and this 'date' field is made in account.analytic.account object. so we must have to use following method, Try this,

class project(osv.Model):
    _inherit = "project.project"
    _order = 'date2'
    _columns = {
        'date2': fields.related('analytic_account_id', 'date', string="End Date", type='date', store=True),

and no need of _name = 'project.project' so,


_name = 'project.project'

Hope it work for you.

I tried your edited content (just remove _name = 'project.project') but I still get the same error as in the original question ("ProgrammingError: column "date" does not exist")...

Yoshi Tashiro
on 7/7/13, 7:18 AM

Hey Ypshi, see my updated answer. the problem was, date field is made in account.analytic.account object. so we can not order date field directly from project.

Ghanshyam Prajapati
on 7/7/13, 7:39 AM

Hey Yoshi, Is your problem is solved?? if yes then please mark my answer as solved. Thanks.

Ghanshyam Prajapati
on 7/7/13, 8:05 AM

I still get the error "ProgrammingError: column project_project.date does not exist". Something must be missing...

Yoshi Tashiro
on 7/7/13, 11:55 AM

You must have to update your module. Go through Settings >> Modules >> Installed Modules. search your module and upgrade it.

Ghanshyam Prajapati
on 7/8/13, 2:41 AM

I totally forgot to do that. It solved the problem. Then I got another problem of "End Date" being blank (thus the sorting didn't work), so I changed the field name to "date2" for the code to work. Thanks a lot for your advice!

Yoshi Tashiro
on 7/8/13, 3:13 AM

please mark my answer as solved if your problem is solved. thanks.. :)

Ghanshyam Prajapati
on 7/8/13, 3:19 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

1 follower(s)


Asked: 7/6/13, 11:18 PM
Seen: 2630 times
Last updated: 3/16/15, 8:10 AM