Odoo 13 Enterprise Edition
Having created a User-defined filter that is shared to all users, I have edited it to include user_id = uid as follows:
["&","&","&",["customer_rank",">",0],["activity_ids","!=",False],["user_id","=", uid],["activity_date_deadline","=","2021-01-12"]]
When saving, I get the following error message: The domain you entered was not properly formatted.I have also tried replacing the static date for activity_date_deadline with a dynamic filter as follows:
["activity_date_deadline", "=", (context_today() + datetime.timedelta(days=1)).strftime('%%Y-%%m-%%d') ]
When saving this, the change is reverted silently - no error is displayed.
Question: How should I edit the User-defined Filter to use dynamic filters for User and Date, please?
What model are you creating this for? Does the model have a user_id field? Take a look at the Filters defined in the sale.order.list.select view which leverage both UID and context_today() https://github.com/odoo/odoo/blob/14.0/addons/sale/views/sale_views.xml#L728
Hi,
i see [] instead of () in your domain. it should be like this:
domain="[(condition), (condition), (condition), (), ..]"
in your case, it is:
[("customer_rank",">",0),("activity_ids","!=",False),("user_id","=", uid),("activity_date_deadline","=","2021-01-12")]
P.S: If all conditions must have and as an operator, no need to add it in the domain.
@Ray Carnes
Thanks for your response. This is being created for the 'Contact' model. The model does have a user_id field - if limiting to a specific named user the filter works - for e.g: ["user_id","ilike","Austen"]
Thank you for the link to the view source that I will test with the the context_today option. If you have any other suggestions for the UID I would certainly appreciate it.
Thank you!
Where are you entering the domain ? Are you using Studio ?
@Alessandro Fiorino and @Ibrahim Boudmir
The steps that I follow are as follows:
1. Go to 'Contacts' and create a filter with the following rules:
---Companies,
---Add Custom Filter: Salesperson contains Austen,
---Add Custom Filter: Next Activity Deadline is equal to 13/01/2021
2. Select the drop-down beside 'Favourites' and select 'Save Current Search'
3. Set the name for the search, and select 'Share with all users' then SAVE.
4. Go to 'Settings' (make sure debug is enabled for this step)
5. Select Technical > User Interface > User-defined Filters
6. Select the custom filter created at step 3 and EDIT
The domain is set automatically when creating the filter from the Contacts module. The corresponding code in the code editor is also created by the action of creating the filter.
I am not using Studio for this task.
Let me know if any further information is required - many thanks.
Any solution? I'm struggling with the same problem... 2 years later ...