跳至内容
菜单
此问题已终结
2 回复
13722 查看

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.

形象
丢弃
最佳答案

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...


形象
丢弃
编写者

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..

编写者

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.

编写者

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?

编写者

Does this method work on version 9?

编写者

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.

编写者

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

最佳答案

Hai Eric!. Follow the below link desc asc  

_order = 'FIELD_NAME asc


_order = 'FIELD_NAME desc'




形象
丢弃
编写者

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

It will work

相关帖文 回复 查看 活动
1
3月 15
5279
1
2月 17
2964
0
6月 24
1377
1
4月 24
1727
8
12月 22
5470