Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2 Replies
5189 Tampilan

I need to add custom filter for a field inside my list view (sale_order_count). How can I add it, I need to filter it like: sale_order_count greater than, less than, etc...

Avatar
Buang
Penulis

Hello, this blog is to add search filter but I need to add custom filter to search by

Jawaban Terbai

Hi Moe,

Please upgrade the module after adding store=True in the field from py side and check.

custom filter conditions are based on the field type. So if you want to see the greater than and less than type of the conditions, then you need to define the fields type as Integer.

Hope it will help you.


Avatar
Buang
Penulis

It worked, but after I made it as store=True the count of all sale order was reset to 0. Why is this problem?

Hi Moe,
Thanks for giving vote for the answer.
Yes, Now your function will call once you change your function dependent fields and calculate the result . Integer field type has the default value 0.

Penulis

Can you give me a glimpse of the code please, I didn't get it so much. You are welcome Malay

Yes sure Moe,
Please try with this

sale_order_count = fields.Integer(compute="_get_sale_order_count", string="Sale Order Count(s)", store=True)

def _get_sale_order_count(self):
for rec in self:
rec.sale_order_count = len(rec.sale_order_ids.ids)

where sale_order_ids is the field inside your model, or search all the sale order ids and add it instead of the len(rec.sale_order_ids.ids)

Please vote up the answer if it helps you.
Thanks

Jawaban Terbai

Hi Moe,

In order to add a custom field in filters ,  the field should be a stored field.

If your field sale_order_count is a computed field, you have to store that field using proper dependencies.

After that you can add that field in filters

Hope this will help you 

Thank You

Avatar
Buang
Penulis

I made the field stored with python code but it is still not showing, any ideas please?

Post Terkait Replies Tampilan Aktivitas
1
Mei 25
987
2
Nov 24
2193
4
Feb 24
12346
sale / delivery Diselesaikan
1
Jan 24
1677
0
Mei 23
1899