Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
4 Replies
7438 Tampilan

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

Avatar
Buang
Penulis Jawaban Terbai

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

Avatar
Buang
Jawaban Terbai

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.

Avatar
Buang
Penulis

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()

Post Terkait Replies Tampilan Aktivitas
3
Mar 22
6975
1
Okt 21
7729
3
Jun 25
980
1
Jan 25
17864
4
Mei 24
12596