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

In Odoo 12 I would like to get 90 days prior (before) to expiry of subscription and automatically and  i have created a email template, i want this by code not by automated action can anyone help me with this.

in py file :

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


Thank You !

Avatar
Discard
Best Answer
Hello ,
You can solve this by following code,
after_90_days= datetime.datetime.now().date() + datetime.timedelta(days=90)
customer_names=self.env['(Model where your field is )'].search([('(field you want to compare)','=',after_90_days)])
customer names will be set of data whose subcription will be due after 90 days.
Thanks & Regards,
Jay R. Dasani
Avatar
Discard
Author

i want a notification before 90 days of the end date of this field renewal_date

Author

will this do for my requirement ?

before_90_days = datetime . datetime . now (). date () + datetime . timedelta ( days = 90)

exp_90days = self . env [ '(sales_asia)' ]. search ([( '(renewal_date)' , '=' , before_90_days )])

yes in exp_90days you will get data set. just remove () from env and field

exp_90days = self . env [ 'sales_asia' ]. search ([( 'renewal_date' , '=' , before_90_days )])