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...
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
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.
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.
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
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
I made the field stored with python code but it is still not showing, any ideas please?
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
2
Nov 24
|
476 | ||
|
4
Feb 24
|
10164 | ||
sale / delivery
Solved
|
|
1
Jan 24
|
369 | |
|
0
May 23
|
831 | ||
|
4
Apr 23
|
38315 |
Hi,
You can try refer the following blog
https://www.cybrosys.com/blog/how-to-add-filters-to-existing-search-view-in-odoo
Hello, this blog is to add search filter but I need to add custom filter to search by