Odoo Help


How to sort projects in Kanban view by name?

on 3/10/15, 4:26 AM 1,070 views

Hi guys,

What is the correct way to order the Kanban from projects?
The first thing I did was to add a default_order in the arch (project_view.xml) but this didn't change anything:

<record model="ir.ui.view" id="view_project_kanban">
            <field name="name">project.project.kanban</field>
            <field name="model">project.project</field>
            <field name="arch" type="xml">
                <kanban class="oe_background_grey">
                   <kanban default_order="name" />
                  //irrelevant code


Then I went into project.py and found the method _get_type_common which orders the projects in kanban view. By default its like this:

def _get_type_common(self, cr, uid, context):
        ids = self.pool.get('project.task.type').search(cr, uid, [('case_default','=',1)], context=context)
        return ids
    _order = "sequence, id"
    //irrelevant code

So I thought I'd change the _order="sequence,id" to _order="name" but the field 'name' is not in the model project.project..So I thought I'd change it to this:

_order = "type_ids.name"

But then I get the following error:


Invalid "order" specified. A valid "order" specification is a comma-separated list of valid field names (optionally followed by asc/desc for the direction) 

So, what is the correct way to order on the name of the project in the Kanban view then?


Update: New code now looks like this:

class project(osv.osv):
    _name = "project.project"
    _description = "Project"
    _inherits = {'account.analytic.account': "analytic_account_id",
                 "mail.alias": "alias_id"}
    _inherit = ['mail.thread', 'ir.needaction_mixin','project.project']
    _order = 'name asc'
    name = fields.char('Account/Contract Name', required=True, track_visibility='onchange')

With kind regards,




| 6 4 7
Lodz, Poland

On 3/10/15, 7:53 AM

Try this:

class project(models.Model):
    _name = "project.project"
    _inherit = ['project.project']
    _order = "name asc"

    name = fields.Char('Account/Contract Name', required=True, track_visibility='onchange')


### name = fields.Char('Account/Contract Name', required=True, track_visibility='onchange')

Thanks for the answer zbik! I've tried this but it gives me KeyError: 'project.project'. I've updated my question with the new code.

on 3/10/15, 8:20 AM


on 3/10/15, 8:28 AM

PS. you inherit only _inherit = ['project.project']

on 3/10/15, 8:48 AM

Zbik I believe your example code is for in a custom module? I would like to simply replace/modify the code in the current project module. In the current module I'd need the 'mail.thread', 'ir.needaction_mixin', too.

on 3/10/15, 9:27 AM

You inherit project.project -> project.project inherit mail.thread and ir.needaction_mixin = you inherit all

on 3/10/15, 10:14 AM

Sorry for the late reply Zbik! So I've created a new module and installed this. Everything works fine until I try to open up any of the projects. I then get a programmingError saying the column doesn't exist. As you can see here: http://i.imgur.com/YSCwmJh.png why is my Odoo throwing this up? The field does exist..

on 3/26/15, 12:08 PM

You can find the module here in case you want to test it / see whats wrong: https://github.com/Yenthe666/order_projects_by_name

on 3/26/15, 12:24 PM

In my test system, I have oher error when create new project and when name = fields.Char() is defined (??? hmmm ???). When I comment this line and update module all works ok.

on 3/26/15, 2:25 PM

I already removed the name field Zbik, as you can see here: https://github.com/Yenthe666/order_projects_by_name/blob/master/order_projects_by_name/models.py but even then I get errors. It only happens when you open up project tasks by clicking on a project, not when showing the project overview etc.

on 3/27/15, 5:25 AM

Strange, I do not have such a issue. Try to remove and re-install the module.

on 3/27/15, 6:48 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 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 E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)


Asked: 3/10/15, 4:26 AM
Seen: 1070 times
Last updated: 3/26/15, 2:34 PM