# -*- coding: utf-8 -*- ################################################################################### # A part of OpenHRMS Project # # Cybrosys Technologies Pvt. Ltd. # Copyright (C) 2018-TODAY Cybrosys Technologies (). # Author: Jesni Banu () # # This program is free software: you can modify # it under the terms of the GNU Affero General Public License (AGPL) as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # ################################################################################### from datetime import datetime from odoo import models, fields, api, _ class HrAnnouncementTable(models.Model): _name = 'hr.announcement' _description = 'HR Announcement' _inherit = ['mail.thread', 'ir.needaction_mixin'] name = fields.Char(string='Code No:') announcement_reason = fields.Text(string='Title', states={'draft': [('readonly', False)]}, required=True, readonly=True) state = fields.Selection([('draft', 'Draft'), ('to_approve', 'Waiting For Approval'), ('approved', 'Approved'), ('done', 'Done'), ('rejected', 'Refused')], string='Status', default='draft', track_visibility='always') requested_date = fields.Date(string='Requested Date', default=datetime.now().strftime('%Y-%m-%d')) attachment_id = fields.Many2many('ir.attachment', 'doc_warning_rel', 'doc_id', 'attach_id4', string="Attachment", help='You can attach the copy of your Letter') company_id = fields.Many2one('res.company', string='Company', default=lambda self: self.env.user.company_id, readonly=True,) is_announcement = fields.Boolean(string='Is general Announcement?') announcement = fields.Html(string='Letter', states={'draft': [('readonly', False)]}, readonly=True) @api.multi def reject(self): self.state = 'rejected' @api.multi def approve(self): self.state = 'approved' @api.multi def set_to_done(self): self.state = 'done' @api.multi def sent(self): self.state = 'to_approve' @api.model def create(self, vals): if vals.get('is_announcement'): vals['name'] = self.env['ir.sequence'].next_by_code('hr.announcement') return super(HrAnnouncementTable, self).create(vals)