Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
4 Trả lời
7538 Lượt xem

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

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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.

Ảnh đại diện
Huỷ bỏ
Tác giả

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

Bài viết liên quan Trả lời Lượt xem Hoạt động
3
thg 3 22
7071
1
thg 10 21
7857
3
thg 6 25
1161
1
thg 1 25
18020
4
thg 5 24
12811