|
|
@ -21,8 +21,8 @@ |
|
|
|
############################################################################# |
|
|
|
|
|
|
|
from datetime import datetime, date, timedelta |
|
|
|
|
|
|
|
from odoo import models, fields, api, _ |
|
|
|
from odoo.exceptions import Warning |
|
|
|
|
|
|
|
|
|
|
|
class HrEmployeeDocument(models.Model): |
|
|
@ -47,18 +47,23 @@ class HrEmployeeDocument(models.Model): |
|
|
|
} |
|
|
|
self.env['mail.mail'].create(main_content).send() |
|
|
|
|
|
|
|
@api.constrains('expiry_date') |
|
|
|
@api.onchange('expiry_date') |
|
|
|
def check_expr_date(self): |
|
|
|
for each in self: |
|
|
|
exp_date = each.expiry_date |
|
|
|
if exp_date < date.today(): |
|
|
|
raise Warning('Your Document Is Already Expired.') |
|
|
|
if exp_date and exp_date < date.today(): |
|
|
|
return { |
|
|
|
'warning': { |
|
|
|
'title': _('Document Expired.'), |
|
|
|
'message': _("Your Document Is Already Expired.") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
name = fields.Char(string='Document Number', required=True, copy=False) |
|
|
|
document_name = fields.Many2one('employee.checklist', string='Document', required=True) |
|
|
|
description = fields.Text(string='Description', copy=False) |
|
|
|
expiry_date = fields.Date(string='Expiry Date', copy=False) |
|
|
|
employee_ref = fields.Many2one('hr.employee', invisible=1, copy=False) |
|
|
|
employee_ref = fields.Many2one('hr.employee', copy=False) |
|
|
|
doc_attachment_id = fields.Many2many('ir.attachment', 'doc_attach_rel', 'doc_id', 'attach_id3', string="Attachment", |
|
|
|
help='You can attach the copy of your document', copy=False) |
|
|
|
issue_date = fields.Date(string='Issue Date', default=fields.Date.context_today, copy=False) |
|
|
|