Hi,
First of all: we cannot provide the domain like you have given.
Currently, It is not possible to set a dynamic domain for the date field in the domain filter.
But, It doesn't matter. You can do it easily with the python code.
If you need to create the maintenance request for the equipments by just comparing the Date of the next preventive maintenance(next_action_date) with current date, you can do it using a scheduled action with code given below(Model: maintenance.equipment, Execute Every: 1 Days):
utc_date_now = datetime.datetime.now()
user_date_now = utc_date_now.astimezone(timezone(user.tz)).date()
equipments_for_maintenance = model.sudo().search([('next_action_date', '=', user_date_now)])
for equipment in equipments_for_maintenance:
env['maintenance.request'].create({
'name': 'Preventive Maintenance - ' + equipment.name,
'equipment_id': equipment.id,
'maintenance_type': 'preventive',
'request_date': equipment.next_action_date,
'schedule_date': equipment.next_action_date,
'duration': record.maintenance_duration
# add the values to the fields in 'maintenance.request'
})
If you need to do the same when we create/ update the Date of the next preventive maintenance(next_action_date), you can create an automated action with the code given below(Model: maintenance.equipment, Trigger: On Creation & Update, Trigger Fields: Date of the next preventive maintenance, Before Update Domain: [], Apply on: [], Action To Do: Execute Python Code):
utc_date_now = datetime.datetime.now()
user_date_now = utc_date_now.astimezone(timezone(user.tz)).date()
if records:
for record in records:
if record.next_action_date == user_date_now:
env['maintenance.request'].create({
'name': 'Preventive Maintenance - ' + record.name,
'equipment_id': record.id,
'maintenance_type': 'preventive',
'request_date': record.next_action_date,
'schedule_date': record.next_action_date,
'duration': record.maintenance_duration
# add the values to the fields in 'maintenance.request'
})
Regards