Skip to Content
Menu
This question has been flagged
2 Replies
12780 Views

I've been trying to modify project object.

and When I click Assign to field, It shows a list of users with dropdown.

But I'd like to change its order to DESC.

Is there any thing I can do in View?

here is my code below

<record id="project_issue_custom_form" model="ir.ui.view">
    <field name="inherit_id" ref="project_issue.project_issue_form_view"/>
    <field name="model">project.issue</field>
    <field name="arch" type="xml">
        <field name="user_id" position="attributes">
            <attribute name="default_order">sequence desc</attribute>
        </field>
    </field>
</record>

Also I tried in controller

class Project_issue(models.Model):
    _inherit = "project.issue"
    _order = "user_id desc"

But It still doesn't affected.

Avatar
Discard
Best Answer

Dear Eric Lee,

Try this:

class res_users(models.Model):
_inherit = "res.users"
_order = "id desc"

and then make your module depends on base module

I hope I helped you...


Avatar
Discard
Author

I made my module depends on project_issue But Still not working.

are you sure make the above code and do upgrade??

without do any something else.

I am sure the above code will solve your issue..

Author

Yes I did nothing without code above. And I tried to modify core source in addons/project_issue/project_issue.py to add user_id desc into _order. But That was not working for form view. Of course I update the module and restart the odoo.

Author

Also When I check its view the field attribute is this <field name="user_id"

context="{'default_groups_ref': ['base.group_user', 'base.group_partner_manager', 'project.group_project_user']}"/> Does this attributes can possibly affect not working sorting?

Author

Does this method work on version 9?

Author

also when I looked at project_issue.py which is at addons, The project_issue class has _order declared already. I guess _order in custom module doesn't override the variable.

Author

The way above worked! I should restart service then it worked! Thanks

Best Answer

Hai Eric!. Follow the below link desc asc  

_order = 'FIELD_NAME asc


_order = 'FIELD_NAME desc'




Avatar
Discard
Author

As I wrote above, _order = "user_id desc" doesn't work at all in form view

It will work

Related Posts Replies Views Activity
1
Mar 15
4580
1
Feb 17
2212
0
Jun 24
355
1
Apr 24
483
8
Dec 22
3969