Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
1 Balas
1466 Tampilan

hello every body,

How can I do daily check if my date (Mymodel.field ) matches today date so schedule an activity 

Avatar
Buang
Jawaban Terbai

Hi,

You can create a scheduled action to execute the following Python code in your model.

check_date = fields.Date(string='Date')


def perform_daily_check(self):

​ today = date.today()

​ records = self.search([('check_date', '=', today)])

​ for record in records:

​ self.env['mail.activity'].create({

​ 'res_id': record.id,

​ 'res_model_id': self.env.ref('my_module.model_my_model').id,

​ 'activity_type_id': self.env.ref('mail.mail_activity_data_todo').id,

​ 'summary': 'Daily Check Activity',

​ 'note': 'Perform daily check for record %s' % record.name,

​ })

How to create a scheduled action 

Scheduled action in v15

Thanks

Thanks

Avatar
Buang

@ Savya Sachin I search about same issue .... so when perform_daily_check this function will execute ?

yes, you should create a scheduled action to execute the above Python code on a daily basis

how add activity as future activity not today activity