تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
4 الردود
7483 أدوات العرض

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

المنشورات ذات الصلة الردود أدوات العرض النشاط
3
مارس 22
7037
1
أكتوبر 21
7819
3
يونيو 25
1075
1
يناير 25
17968
4
مايو 24
12713