Hello.
I want to change state by current date, when choose current date the state automaticaly move (ex from draft to expired)?
How can i do that, thanks
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hello.
I want to change state by current date, when choose current date the state automaticaly move (ex from draft to expired)?
How can i do that, thanks
Thank you for guiding me using Scheduled Action Paresh.
I adding the the model=ir.cron in my .xml and adding python function to change the state from active to expired.
didn't work with:
record.cop_expiry < datetime.datetime.today()
beside of using it, i'm using this:
record.cop_expiry <= fields.Date.today():
It works well to me
Hi Boby:
You can define a Scheduled Action which will run every day after midnight and update the previous day's draft records to expired.
To define the Scheduled Action, you need to activate developer mode and go to Settings > Technical > Scheduled Actions.
With Scheduled Actions how can i know when current date is match with the expired date?
I have this model:
class xapiens_employee(models.Model):
_inherit = 'hr.employee'
certificate_state = fields.Selection(string="COP Status", selection=[
('draft', 'Draft'),
('expired', 'Expired')], readonly=True, default='draft')
class certificate_proficiency(models.Model):
_name = 'hr.certificate.proficiency'
_description = 'Certificate Proficiency'
_rec_name = 'certificate_name_cop'
cop_emp_id = fields.Many2one('hr.employee', string="COP Employee Name")
cop_file_name = fields.Char(String="File Name COP")
certificate_name_cop = fields.Many2one('hr.certificate.proficiency.name', string="Certificate Name")
cop_number = fields.Char('Number')
cop_issue = fields.Date('Issued')
cop_expiry = fields.Date('Expiry'))
When Date Today is match with cop_expiry, the certificate_state move to expired
Based on your description of what you are trying to do, you need to check for records where expiry date is before the date on which the job runs.
record.cop_expiry < datetime.datetime.today()