Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
2117 Lượt xem

I want to add a filter to group the timesheet tree by a custom field.


This is what I have:


< record id="hr_timesheet_line_my_timesheet_search_ext" model="ir.ui.view">
< field name="name">view.search.my.timesheet.menu.ext< /field>
< field name="model">account.analytic.line< /field>
< field name="inherit_id" ref="hr_timesheet.hr_timesheet_line_my_timesheet_search"/>
< field name="arch" type="xml">
< search string="Timesheet">
< group expand="0" string="Group By">
< filter name="group_by_custom_field" string="Custom Field" icon="terp-partner" context="{'group_by':'custom_field'}"/>
< /group>
< /search>
< /field>
< /record>

But the custom field is not showing in the groupby dropdown.

Thank you


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi Brend: The custom field needs to be defined as a Stored field if you want to use it for filter/sort/group by. Make sure the store attribute of the field is set to True.

Ảnh đại diện
Huỷ bỏ
Tác giả

Hi Paresh,
I set store=True already, still the custom field is not showing in the groupby dropdown..

Try using xpath expr="/search" format for the customization instead of just "search". The search view seems to be inherited through multiple levels of inheritance.

Câu trả lời hay nhất

Try this ==> < xpath expr="//filter[@name='salesperson']" position="before" >

< filter name="group_by_custom_field" string="Custom Field" icon="terp-partner" context="{'group_by':'custom_field'}"/>

< /xpath>

Ảnh đại diện
Huỷ bỏ
Tác giả

Still the custom field is not showing in the groupby dropdown..

what is the type of field and your view is loaded in odoo properly?

Tác giả

It's a Datetime field.
What do you mean with view loaded in view?

You have done like this ?

< record id="hr_timesheet_line_my_timesheet_search_ext" model="ir.ui.view">
< field name="name">view.search.my.timesheet.menu.ext< /field>
< field name="model">account.analytic.line< /field>
< field name="inherit_id" ref="hr_timesheet.hr_timesheet_line_my_timesheet_search"/>
< field name="arch" type="xml">
< xpath expr="//filter[@name='filter_name']" position="after" >
< filter name="group_by_custom_field" string="Custom Field" icon="terp-partner" context="{'group_by':'custom_field'}"/>
</xpath>
< /field>
< /record>

Tác giả

Yes, that's exactly what I did

Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 7 24
2600
1
thg 6 24
5068
1
thg 10 23
10743
1
thg 10 23
98
1
thg 8 23
2193