This question has been flagged
1 Reply
3115 Views

 I've set up an automated action related to claims module, so as to send automatically a reminder email, one day before the claim's deadline date. I overwrited the type of date_deadline to datetime. it was date type before. 

Now the my automated action is created with the following parameters : 

Model : crm_clam
Timer : Trigger date = date_deadline - 1 day ; so as to trigger the automated action one day before the deadline datetime.

Action : server action described below 

Server action :

To send the mail I made a server action of type : Python code, where I called the email the template to be sent following a condition.

I tried to make a time condition that triggers the server action only if the deadline date still not passed.   

Here after the server action :

# You can use the following variables:

# - self: ORM model of the record on which the action is triggered

# - object: browse_record of the record on which the action is triggered if there is one, otherwise None

# - pool: ORM model pool (i.e. self.pool)

# - time: Python time module

# - cr: database cursor

# - uid: current user id

# - context: current context

# If you plan to return an action, assign: action = {...}

from datetime import datetime

tmpl_obj = self.pool.get('email.template')

tmpl_ids = tmpl_obj.search(cr, uid, ids, [('name','=','Rappel Reclamation')])

if tmpl_ids and datetime.strptime(object.date_deadline,"%Y-%m-%d").date() >= datetime.now().date():

      tmpl_obj.send_mail(cr,uid, tmpl_ids[0], object.id,True)

It marked that we can use the time module, how can we use it to achieve the condition ?

The email is not triggered, 

Suggestions please ?

Avatar
Discard