Skip to Content
Menu
This question has been flagged
3 Replies
6205 Views

i want to minus datetime.timedelta (days = 90) that is 90 days from the license_renewal_date = (2021,6,6) how to do it

before_90_days = datetime.datetime.now (). date () - datetime.timedelta (days = 90) datetime.date (2020, 3, 11)

license_renewal_date = (2021,6,6)

exp_90_days = license_renewal_date - datetime.timedelta (days = 90)

Traceback (most recent call last): File "", line 1, in TypeError: unsupported operand type (s) for -: 'tuple' and 'datetime.timedelta'

in odoo: py file -license_renewal_date = fields.Date ("Renewal Date", track_visibility = 'onchange')

def exp_date1(self):
    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(rec.id, force_send=True)   
Avatar
Discard
Best Answer

            today = fields.Datetime.now()

            before_ninety_days= today - timedelta(days=90)

Output

today                     

- 2020-06-10 07:55:06

before_ninety_days 

-  2020-03-12 07:55:06

hope this will help :)

Avatar
Discard
Author Best Answer

   i have update still getting the same error some one help me with his

@ api.multi

    def exp_date1 (self):

        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) 

Avatar
Discard