Skip to Content
Menu
This question has been flagged
1 Reply
1272 Views

iam new to odoo what iam trying to do is, i want to minus datetime.timedelta (days = 90) that is 90 days from the license_renewal_date  how to do it,

in py file :

license_renewal_date = fields.Date("Renewal Date",track_visibility='onchange')


@ api.multi def exp_date1 (self): testDateOnly = datetime.datetime (license_renewal_date.date) #testDateOnly = license_renewal_date.date; before_90_days = testDateOnly - datetime.timedelta (days = 90) # before_90_days = datetime.datetime.now (). date () - datetime.timedelta (days = 90) exp_90days = self.env ['crm.lead.extended']. search ([('license_renewal_date', '=', before_90_days)]) template = self.env.ref ('crm_extended.create_crm_lead_mail_template') template.send_mail (self.id, force_send = True)

i have created a mail template too configured outgoing mail server , but iam not reciveing any mails when it meets the criteria , but i receive when any change is made to this field :

    lead_status = fields.Many2one ("crm.stage", "Lead Status", track_visibility = 'onchange', default = _get_default_lead_status)


    @ api.multi

    def write (self, vals):

        if 'lead_status' in vals and self.ids:

            for rec in self:

                template = self.env.ref ('crm_extended.crm_lead_mail_template')

                template.send_mail (rec.id, force_send = True)          

        return super (crm_extended, self) .write (vals)






Avatar
Discard

Send email on some event: https://goo.gl/z16PBZ