You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

67 lines
2.9 KiB

# -*- coding: utf-8 -*-
###################################################################################
# A part of OpenHRMS Project <https://www.openhrms.com>
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2018-TODAY Cybrosys Technologies (<https://www.cybrosys.com>).
# Author: Jesni Banu (<https://www.cybrosys.com>)
#
# 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 <https://www.gnu.org/licenses/>.
#
###################################################################################
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)