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.
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.
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).