Odoo 9 How to sort a form order for a field

I am trying to modify a project release object.

and when I click "Assign to box", it shows a list of users with a drop-down list.

But I would like to change its order to DESC.

Is there anything 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>

I also tried in the controller

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

But it still does not affect.

+4
source share
1 answer

The tag default_ordercan only be used for lists and types of kanban. But you want to reorder the contents of the many2one ( user_idon project.issue) field .

Your second approach has potential. But this is the wrong model:

class ResUsers(models.Model):
    _inherit = "res.users"
    _order = "name desc"  # or id
+2

Source: https://habr.com/ru/post/1679306/


All Articles