Thanks for this Chris. Can you help me also find sales orders confirmed in the last 365 days? This kind of filter would then allow a rolling year in automation.
You will need to add a custom related field (sale_order_ids.date_order) to the res.partner model. This field will then be available in the filter and you will be able to select a date range.
EDIT:
Added screenshot as requested.
Custom Field definition:
What the Filter will look like on the Contacts screen:
What the results will look like (sample using demo data):
It is a good solution, but to help anyone who wants to use it I think this is going to select both quotations and confirmed sales orders in the date range. It should be easy to add selection of confirmed sales orders only to the user-defined filter.
Nice catch Chris. I didn't see the "confirmed sales order" part of the requirement. You're right, this will select both quotations and sales orders.
Since a "related field" was used for this, the domain field is not available in the configuration screen of the field definition. Also tried adding a second filter field for the order state but using both criteria to filter the partners does not work as expected and seems to use an OR instead of an AND condition. Looks like a custom filter will need to be developed for this requirement.
hi! This is absolutely wonderful, thanks!! How would I be able to sort by this related field? That's the only thing I can't figure out. Thanks again! Peat
Hi @Patresh, thank you for the solution. Right know i'm working on function to filter and deactivate automatically customers with invoice date more than 365days. Can you help me please. Thank you.
If you want to filter this in Marketing Automation you can
1. Create a new boolean field x_recent_sales_orders
2. Create an automated action
Enable Developer Mode and navigate to Settings / Technical / (Automation) / Automated Actions:
for rec in records: rec['x_recent_sales_orders'] = False if rec.x_sales_order_dates: if rec.x_sales_order_dates > (datetime.datetime.today() - datetime.timedelta(days=5)): rec['x_recent_sales_orders'] = True
What's missing here is the automatic update to reset this flag.
To do it properly, I think you'd need a developer to setup a Scheduled Action to run this code daily (or weekly).
As a workaround, it is also possible to create a Contextual Action and then you could manually run this (by selecting all orders).
After creating this field and adding the Automated Action you can use it as a filter in Marketing Automation.
Thank you Chris that works incredibly well in the Customers view.
Could you give some guidance as to when setting and finding this filter in an Automation? Whilst I can find the filter in Customers, I cannot find it here:
I would like to edit this post once it is done to make it clear for all users - thanks for your help.
Odoo has a "simplified" version of the filter in various places and that only allows specific dates to be entered. There is a workaround for this as described here: https://odootricks.tips/domain-in-odoo/#problem but it seems that doesn't work for Marketing Automation.
Another solution is to create a boolean field that will identify customers who have placed orders recently (e.g. last 12 months) and update this every day using a Scheduled Action (then you can easily add a filter).
From what you say I realised I don't need to use Marketing Automation to sort my database contacts and their opportunities. I can use scheduled actions instead.
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Thanks for this Chris. Can you help me also find sales orders confirmed in the last 365 days? This kind of filter would then allow a rolling year in automation.
Thank you Chris,
So you are saying I need to create a new field and a new extension view with that code?
Yes, that's the idea. I have added more details (see below).