20 changed files with 946 additions and 0 deletions
@ -0,0 +1,17 @@ |
|||||
|
OH Reward/Warning |
||||
|
--------------------- |
||||
|
Supporting Addon for Open HRMS, Managing Official Announcements |
||||
|
|
||||
|
Connect with experts |
||||
|
-------------------- |
||||
|
|
||||
|
If you have any question/queries/additional works on OpenHRMS or this module, You can drop an email directly to Cybrosys. |
||||
|
|
||||
|
Contacts |
||||
|
-------- |
||||
|
info - info@cybrosys.com |
||||
|
Jesni Banu - jesni@cybrosys.in |
||||
|
|
||||
|
Website: |
||||
|
https://www.openhrms.com |
||||
|
https://www.cybrosys.com |
@ -0,0 +1,6 @@ |
|||||
|
## Module <hr_reward_warning> |
||||
|
|
||||
|
#### 30.03.2018 |
||||
|
#### Version 10.0.1.0.0 |
||||
|
##### ADD |
||||
|
- Initial commit for OpenHrms Project |
@ -0,0 +1,26 @@ |
|||||
|
# -*- 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 . import models |
||||
|
|
||||
|
|
||||
|
|
@ -0,0 +1,47 @@ |
|||||
|
# -*- 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/>. |
||||
|
# |
||||
|
################################################################################### |
||||
|
{ |
||||
|
'name': 'OHRMS Official Announcements', |
||||
|
'version': '10.0.1.0.0', |
||||
|
'summary': """Managing Official Announcements""", |
||||
|
'description': 'This module helps you to manage hr official announcements', |
||||
|
'category': 'Generic Modules/Human Resources', |
||||
|
'author': 'Cybrosys Techno Solutions', |
||||
|
'company': 'Cybrosys Techno Solutions', |
||||
|
'website': "https://www.openhrms.com", |
||||
|
'depends': ['base', 'hr_payroll'], |
||||
|
'data': [ |
||||
|
'security/ir.model.access.csv', |
||||
|
'security/reward_security.xml', |
||||
|
'views/hr_reward_warning_view.xml', |
||||
|
'views/hr_employee_view.xml', |
||||
|
'data/reward_rule.xml', |
||||
|
'reports/letter.xml', |
||||
|
], |
||||
|
'demo': [], |
||||
|
'images': ['static/description/banner.jpg'], |
||||
|
'license': 'AGPL-3', |
||||
|
'installable': True, |
||||
|
'auto_install': False, |
||||
|
'application': False, |
||||
|
} |
@ -0,0 +1,29 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<odoo> |
||||
|
<data> |
||||
|
<record id="hr_payslip_rule_warning" model="hr.salary.rule"> |
||||
|
<field name="code">SWR</field> |
||||
|
<field name="name">Warning Amount</field> |
||||
|
<field name="category_id" ref="hr_payroll.DED"/> |
||||
|
<field name="amount_select">code</field> |
||||
|
<field name="amount_python_compute">result = -(payslip.warning_amount)</field> |
||||
|
<field name="appears_on_payslip" eval="True"/> |
||||
|
<field name="sequence" eval="190"/> |
||||
|
</record> |
||||
|
|
||||
|
<record id="hr_payslip_rule_reward" model="hr.salary.rule"> |
||||
|
<field name="code">SRR</field> |
||||
|
<field name="name">Reward</field> |
||||
|
<field name="category_id" ref="hr_payroll.ALW"/> |
||||
|
<field name="amount_select">code</field> |
||||
|
<field name="amount_python_compute">result = payslip.reward_amount</field> |
||||
|
<field name="appears_on_payslip" eval="True"/> |
||||
|
<field name="sequence" eval="190"/> |
||||
|
</record> |
||||
|
|
||||
|
<record id="hr_payroll.structure_base" model="hr.payroll.structure"> |
||||
|
<field eval="[(4, ref('hr_payslip_rule_warning')), (4, ref('hr_payslip_rule_reward'))]" |
||||
|
name="rule_ids"/> |
||||
|
</record> |
||||
|
</data> |
||||
|
</odoo> |
@ -0,0 +1,26 @@ |
|||||
|
# -*- 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 . import hr_warning |
||||
|
from . import hr_employee |
||||
|
|
||||
|
|
@ -0,0 +1,202 @@ |
|||||
|
# -*- 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 odoo import models, fields, api, _ |
||||
|
|
||||
|
|
||||
|
class HrRewardWarning(models.Model): |
||||
|
_inherit = 'hr.employee' |
||||
|
|
||||
|
warning_count = fields.Integer(compute='_warning_count', string='# Warnings') |
||||
|
reward_count = fields.Integer(compute='_reward_count', string='# Rewards') |
||||
|
ann_count = fields.Integer(compute='_ann_count', string='# Announcements') |
||||
|
letter_count = fields.Integer(compute='_letter_count', string='# Letters') |
||||
|
|
||||
|
@api.multi |
||||
|
def _warning_count(self): |
||||
|
for each in self: |
||||
|
warning_ids = self.env['hr.reward.warning'].sudo().search([('employee_id', '=', each.id), |
||||
|
('hr_type', '=', 'warning'), |
||||
|
('state', 'in', ('approved', 'done'))]) |
||||
|
each.warning_count = len(warning_ids) |
||||
|
|
||||
|
@api.multi |
||||
|
def _letter_count(self): |
||||
|
for each in self: |
||||
|
letter_ids = self.env['hr.reward.warning'].sudo().search([('employee_id', '=', each.id), |
||||
|
('hr_type', '=', 'letter'), |
||||
|
('state', 'in', ('approved', 'done'))]) |
||||
|
each.letter_count = len(letter_ids) |
||||
|
|
||||
|
@api.multi |
||||
|
def _reward_count(self): |
||||
|
for each in self: |
||||
|
reward_ids = self.env['hr.reward.warning'].sudo().search([('employee_id', '=', each.id), |
||||
|
('hr_type', '=', 'reward'), |
||||
|
('state', 'in', ('approved', 'done'))]) |
||||
|
each.reward_count = len(reward_ids) |
||||
|
|
||||
|
@api.multi |
||||
|
def _ann_count(self): |
||||
|
for each in self: |
||||
|
ann_ids = self.env['hr.reward.warning'].sudo().search([('is_announcement', '=', True), |
||||
|
('state', 'in', ('approved', 'done'))]) |
||||
|
each.ann_count = len(ann_ids) |
||||
|
|
||||
|
@api.multi |
||||
|
def warning_view(self): |
||||
|
for each1 in self: |
||||
|
warning_obj = self.env['hr.reward.warning'].sudo().search([('employee_id', '=', each1.id), |
||||
|
('hr_type', '=', 'warning'), |
||||
|
('state', 'in', ('approved', 'done'))]) |
||||
|
warning_ids = [] |
||||
|
for each in warning_obj: |
||||
|
warning_ids.append(each.id) |
||||
|
view_id = self.env.ref('hr_reward_warning.view_hr_reward_warning_form').id |
||||
|
if warning_ids: |
||||
|
if len(warning_ids) <= 1: |
||||
|
value = { |
||||
|
'view_type': 'form', |
||||
|
'view_mode': 'form', |
||||
|
'res_model': 'hr.reward.warning', |
||||
|
'view_id': view_id, |
||||
|
'type': 'ir.actions.act_window', |
||||
|
'name': _('Warnings'), |
||||
|
'res_id': warning_ids and warning_ids[0] |
||||
|
} |
||||
|
else: |
||||
|
value = { |
||||
|
'domain': str([('id', 'in', warning_ids)]), |
||||
|
'view_type': 'form', |
||||
|
'view_mode': 'tree,form', |
||||
|
'res_model': 'hr.reward.warning', |
||||
|
'view_id': False, |
||||
|
'type': 'ir.actions.act_window', |
||||
|
'name': _('Warnings'), |
||||
|
'res_id': warning_ids |
||||
|
} |
||||
|
|
||||
|
return value |
||||
|
|
||||
|
@api.multi |
||||
|
def letter_view(self): |
||||
|
for each1 in self: |
||||
|
letter_obj = self.env['hr.reward.warning'].sudo().search([('employee_id', '=', each1.id), |
||||
|
('hr_type', '=', 'letter'), |
||||
|
('state', 'in', ('approved', 'done'))]) |
||||
|
letter_ids = [] |
||||
|
for each in letter_obj: |
||||
|
letter_ids.append(each.id) |
||||
|
view_id = self.env.ref('hr_reward_warning.view_hr_reward_warning_form').id |
||||
|
if letter_ids: |
||||
|
if len(letter_ids) <= 1: |
||||
|
value = { |
||||
|
'view_type': 'form', |
||||
|
'view_mode': 'form', |
||||
|
'res_model': 'hr.reward.warning', |
||||
|
'view_id': view_id, |
||||
|
'type': 'ir.actions.act_window', |
||||
|
'name': _('Letters'), |
||||
|
'res_id': letter_ids and letter_ids[0] |
||||
|
} |
||||
|
else: |
||||
|
value = { |
||||
|
'domain': str([('id', 'in', letter_ids)]), |
||||
|
'view_type': 'form', |
||||
|
'view_mode': 'tree,form', |
||||
|
'res_model': 'hr.reward.warning', |
||||
|
'view_id': False, |
||||
|
'type': 'ir.actions.act_window', |
||||
|
'name': _('Letters'), |
||||
|
'res_id': letter_ids |
||||
|
} |
||||
|
|
||||
|
return value |
||||
|
|
||||
|
@api.multi |
||||
|
def reward_view(self): |
||||
|
for each1 in self: |
||||
|
reward_obj = self.env['hr.reward.warning'].sudo().search([('employee_id', '=', each1.id), |
||||
|
('hr_type', '=', 'reward'), |
||||
|
('state', 'in', ('approved', 'done'))]) |
||||
|
reward_ids = [] |
||||
|
for each in reward_obj: |
||||
|
reward_ids.append(each.id) |
||||
|
view_id = self.env.ref('hr_reward_warning.view_hr_reward_warning_form').id |
||||
|
if reward_ids: |
||||
|
if len(reward_ids) <= 1: |
||||
|
value = { |
||||
|
'view_type': 'form', |
||||
|
'view_mode': 'form', |
||||
|
'res_model': 'hr.reward.warning', |
||||
|
'view_id': view_id, |
||||
|
'type': 'ir.actions.act_window', |
||||
|
'name': _('Rewards'), |
||||
|
'res_id': reward_ids and reward_ids[0] |
||||
|
} |
||||
|
else: |
||||
|
value = { |
||||
|
'domain': str([('id', 'in', reward_ids)]), |
||||
|
'view_type': 'form', |
||||
|
'view_mode': 'tree,form', |
||||
|
'res_model': 'hr.reward.warning', |
||||
|
'view_id': False, |
||||
|
'type': 'ir.actions.act_window', |
||||
|
'name': _('Rewards'), |
||||
|
'res_id': reward_ids |
||||
|
} |
||||
|
|
||||
|
return value |
||||
|
|
||||
|
@api.multi |
||||
|
def announcement_view(self): |
||||
|
for each1 in self: |
||||
|
ann_obj = self.env['hr.reward.warning'].sudo().search([('is_announcement', '=', True), |
||||
|
('state', 'in', ('approved', 'done'))]) |
||||
|
ann_ids = [] |
||||
|
for each in ann_obj: |
||||
|
ann_ids.append(each.id) |
||||
|
view_id = self.env.ref('hr_reward_warning.view_hr_reward_warning_form').id |
||||
|
if ann_ids: |
||||
|
if len(ann_ids) <= 1: |
||||
|
value = { |
||||
|
'view_type': 'form', |
||||
|
'view_mode': 'form', |
||||
|
'res_model': 'hr.reward.warning', |
||||
|
'view_id': view_id, |
||||
|
'type': 'ir.actions.act_window', |
||||
|
'name': _('Announcements'), |
||||
|
'res_id': ann_ids and ann_ids[0] |
||||
|
} |
||||
|
else: |
||||
|
value = { |
||||
|
'domain': str([('id', 'in', ann_ids)]), |
||||
|
'view_type': 'form', |
||||
|
'view_mode': 'tree,form', |
||||
|
'res_model': 'hr.reward.warning', |
||||
|
'view_id': False, |
||||
|
'type': 'ir.actions.act_window', |
||||
|
'name': _('Announcements'), |
||||
|
'res_id': ann_ids |
||||
|
} |
||||
|
|
||||
|
return value |
@ -0,0 +1,246 @@ |
|||||
|
# -*- 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 HrRewardWarning(models.Model): |
||||
|
_name = 'hr.reward.warning' |
||||
|
_description = 'HR Reward Warning' |
||||
|
_inherit = ['mail.thread', 'ir.needaction_mixin'] |
||||
|
|
||||
|
@api.multi |
||||
|
def reject(self): |
||||
|
self.state = 'rejected' |
||||
|
|
||||
|
@api.model |
||||
|
def create(self, vals): |
||||
|
if vals.get('hr_type') == 'reward': |
||||
|
vals['name'] = self.env['ir.sequence'].next_by_code('hr.loan.reward') |
||||
|
elif vals.get('hr_type') == 'warning': |
||||
|
vals['name'] = self.env['ir.sequence'].next_by_code('hr.loan.warning') |
||||
|
elif vals.get('hr_type') == 'letter': |
||||
|
vals['name'] = self.env['ir.sequence'].next_by_code('hr.loan.letter') |
||||
|
if vals.get('is_announcement'): |
||||
|
vals['name'] = self.env['ir.sequence'].next_by_code('hr.loan.announcement') |
||||
|
return super(HrRewardWarning, self).create(vals) |
||||
|
|
||||
|
@api.multi |
||||
|
def sent(self): |
||||
|
self.state = 'to_approve' |
||||
|
|
||||
|
@api.multi |
||||
|
def set_to_draft(self): |
||||
|
self.state = 'draft' |
||||
|
|
||||
|
@api.multi |
||||
|
def approve(self): |
||||
|
letter = _('<table><tr colspan="2"><td>%s</td></tr><tr><td><h4><b>Approved by</b></h4><br/>%s</td>' |
||||
|
'<td></td></tr></table>') % (self.letter, self.env.user.signature) |
||||
|
partner_ids = [] |
||||
|
if self.letter: |
||||
|
self.letter = letter |
||||
|
if self.hr_type == 'warning': |
||||
|
subject = 'Warning: ' + self.reason |
||||
|
body = '' |
||||
|
elif self.hr_type == 'reward': |
||||
|
subject = 'Reward: ' + self.reason |
||||
|
body = _('<h3>Congrats %s<br/></h3>') % self.employee_id.name |
||||
|
elif self.hr_type == 'letter': |
||||
|
subject = 'Letter: ' + self.reason |
||||
|
body = '' |
||||
|
if self.is_announcement: |
||||
|
subject = 'Announcement: ' + self.reason |
||||
|
body = '' |
||||
|
if self.is_announcement: |
||||
|
email_to = self.env.user.email |
||||
|
emp_obj = self.env['hr.employee'].search([]) |
||||
|
for each in emp_obj: |
||||
|
if each.work_email: |
||||
|
email_to = email_to + ',' + each.work_email |
||||
|
if each.user_id: |
||||
|
partner_ids.append(each.user_id.partner_id.id) |
||||
|
main_content = { |
||||
|
'subject': subject, |
||||
|
'author_id': self.env.user.partner_id.id, |
||||
|
'body_html': body + self.letter, |
||||
|
'email_to': email_to, |
||||
|
} |
||||
|
else: |
||||
|
if self.employee_id.user_id: |
||||
|
partner_ids.append(self.employee_id.user_id.partner_id.id) |
||||
|
main_content = { |
||||
|
'subject': subject, |
||||
|
'author_id': self.env.user.partner_id.id, |
||||
|
'body_html': body + self.letter, |
||||
|
'email_to': self.employee_id.work_email, |
||||
|
} |
||||
|
mail_id = self.env['mail.mail'].create(main_content) |
||||
|
if self.attachment_id: |
||||
|
att_ids = [] |
||||
|
for each in self.attachment_id: |
||||
|
att_ids.append(each.id) |
||||
|
mail_id.write({'attachment_ids': [(6, 0, [aid for aid in att_ids])]}) |
||||
|
mail_id.send() |
||||
|
mail_id.mail_message_id.write({'needaction_partner_ids': [(4, pid) for pid in partner_ids]}) |
||||
|
mail_id.mail_message_id.write({'partner_ids': [(4, pid) for pid in partner_ids]}) |
||||
|
self.state = 'approved' |
||||
|
|
||||
|
@api.multi |
||||
|
def set_to_done(self): |
||||
|
self.state = 'done' |
||||
|
|
||||
|
name = fields.Char(string='Code No:') |
||||
|
company_id = fields.Many2one('res.company', 'Company', readonly=True, |
||||
|
default=lambda self: self.env.user.company_id) |
||||
|
email_send = fields.Boolean(default=False, invisible=1, track_visibility='always', copy=False) |
||||
|
is_announcement = fields.Boolean(string='Is general Announcement?') |
||||
|
requested_date = fields.Date(string='Requested Date', default=datetime.now().strftime('%Y-%m-%d')) |
||||
|
employee_id = fields.Many2one('hr.employee', string='Employee', readonly=True, |
||||
|
states={'draft': [('readonly', False)]}) |
||||
|
hr_type = fields.Selection([('warning', 'Warning'), ('reward', 'Reward'), ('letter', 'Letter')], string='Type', |
||||
|
readonly=True, states={'draft': [('readonly', False)]}) |
||||
|
amount = fields.Float(string='Amount') |
||||
|
attachment_id = fields.Many2many('ir.attachment', 'doc_warning_rel', 'doc_id', 'attach_id4', |
||||
|
string="Attachment", help='You can attach the copy of your Letter') |
||||
|
reason = fields.Text(string='Title', readonly=True, states={'draft': [('readonly', False)]}, required=True) |
||||
|
letter = fields.Html(string='Letter', readonly=True, states={'draft': [('readonly', False)]}) |
||||
|
state = fields.Selection([('draft', 'Draft'), ('to_approve', 'Waiting For Approval'), ('approved', 'Approved'), |
||||
|
('done', 'Done'), ('rejected', 'Refused')], string='Status', default='draft', |
||||
|
track_visibility='always') |
||||
|
month_of_action = fields.Selection([('1', 'January'), ('2', 'February'), ('3', 'March'), |
||||
|
('4', 'April'), ('5', 'May'), ('6', 'June'), |
||||
|
('7', 'July'), ('8', 'August'), ('9', 'September'), |
||||
|
('10', 'October'), ('11', 'November'), ('12', 'December')], |
||||
|
help="Month of action for to generate payslip", |
||||
|
string='Requested Month', readonly=True, states={'draft': [('readonly', False)]}) |
||||
|
|
||||
|
|
||||
|
class HrEmployeeWarningAttachment(models.Model): |
||||
|
_inherit = 'ir.attachment' |
||||
|
|
||||
|
doc_warning_rel = fields.Many2many('hr.reward.warning', 'attachment_id', 'attach_id4', 'doc_id', |
||||
|
string="Attachment", invisible=1) |
||||
|
|
||||
|
|
||||
|
class RewardHrPayslip(models.Model): |
||||
|
_inherit = 'hr.payslip' |
||||
|
|
||||
|
warning_amount = fields.Float('Warning Amount', compute='add_warning', store='True') |
||||
|
reward_amount = fields.Float('Reward Amount', compute='add_reward', store='True') |
||||
|
|
||||
|
@api.multi |
||||
|
def action_payslip_done(self): |
||||
|
for each in self: |
||||
|
current_month = datetime.strptime(each.date_from, "%Y-%m-%d").month |
||||
|
if each.warning_amount: |
||||
|
warnings = self.env['hr.reward.warning'].search([('employee_id', '=', each.employee_id.id), |
||||
|
('state', '=', 'approved'), |
||||
|
('hr_type', '=', 'warning'), |
||||
|
('month_of_action', '=', current_month)]) |
||||
|
for each1 in warnings: |
||||
|
each1.write({'state': 'done'}) |
||||
|
if each.reward_amount: |
||||
|
rewards = self.env['hr.reward.warning'].search([('employee_id', '=', each.employee_id.id), |
||||
|
('state', '=', 'approved'), |
||||
|
('hr_type', '=', 'reward'), |
||||
|
('month_of_action', '=', current_month)]) |
||||
|
for each1 in rewards: |
||||
|
each1.write({'state': 'done'}) |
||||
|
return super(RewardHrPayslip, self).action_payslip_done() |
||||
|
|
||||
|
@api.depends('employee_id') |
||||
|
def add_warning(self): |
||||
|
for each in self: |
||||
|
warning_amount = 0 |
||||
|
current_month = datetime.strptime(each.date_from, "%Y-%m-%d").month |
||||
|
warnings = self.env['hr.reward.warning'].search([('employee_id', '=', each.employee_id.id), |
||||
|
('state', '=', 'approved'), |
||||
|
('hr_type', '=', 'warning'), |
||||
|
('month_of_action', '=', current_month)]) |
||||
|
for each1 in warnings: |
||||
|
warning_amount += each1.amount |
||||
|
each.warning_amount = warning_amount |
||||
|
|
||||
|
@api.depends('employee_id') |
||||
|
def add_reward(self): |
||||
|
for each in self: |
||||
|
reward_amount = 0 |
||||
|
current_month = datetime.strptime(each.date_from, "%Y-%m-%d").month |
||||
|
rewards = self.env['hr.reward.warning'].search([('employee_id', '=', each.employee_id.id), |
||||
|
('state', '=', 'approved'), |
||||
|
('hr_type', '=', 'reward'), |
||||
|
('month_of_action', '=', current_month)]) |
||||
|
for each1 in rewards: |
||||
|
reward_amount += each1.amount |
||||
|
each.reward_amount = reward_amount |
||||
|
|
||||
|
|
||||
|
class WizardSendMail(models.TransientModel): |
||||
|
_name = 'wizard.send.mail' |
||||
|
|
||||
|
@api.multi |
||||
|
def send_now(self): |
||||
|
context = self._context |
||||
|
reward_obj = self.env['hr.reward.warning'].search([('id', '=', context.get('reward_id'))]) |
||||
|
partner_ids = [] |
||||
|
if reward_obj.hr_type == 'warning': |
||||
|
subject = 'Warning: ' + reward_obj.reason |
||||
|
elif reward_obj.hr_type == 'reward': |
||||
|
subject = 'Reward: ' + reward_obj.reason |
||||
|
elif reward_obj.hr_type == 'letter': |
||||
|
subject = 'Letter: ' + reward_obj.reason |
||||
|
if reward_obj.is_announcement: |
||||
|
subject = 'Announcement: ' + reward_obj.reason |
||||
|
if not reward_obj.is_announcement: |
||||
|
if self.department_ids: |
||||
|
body = 'Hi Team, <br/>' |
||||
|
email_to = self.env.user.email |
||||
|
email_ids = [] |
||||
|
for each in self.department_ids: |
||||
|
for each1 in each.member_ids: |
||||
|
if each1.work_email: |
||||
|
if each1.work_email not in email_ids: |
||||
|
email_ids.append(each1.work_email) |
||||
|
email_to = email_to + ',' + each1.work_email |
||||
|
if each1.user_id: |
||||
|
if each1.user_id not in partner_ids: |
||||
|
partner_ids.append(each1.user_id.partner_id.id) |
||||
|
main_content = { |
||||
|
'subject': subject, |
||||
|
'author_id': self.env.user.partner_id.id, |
||||
|
'body_html': body + reward_obj.letter, |
||||
|
'email_to': email_to, |
||||
|
} |
||||
|
mail_id = self.env['mail.mail'].create(main_content) |
||||
|
if reward_obj.attachment_id: |
||||
|
att_ids = [] |
||||
|
for each in reward_obj.attachment_id: |
||||
|
att_ids.append(each.id) |
||||
|
mail_id.write({'attachment_ids': [(6, 0, [aid for aid in att_ids])]}) |
||||
|
mail_id.send() |
||||
|
mail_id.mail_message_id.write({'needaction_partner_ids': [(4, pid) for pid in partner_ids]}) |
||||
|
mail_id.mail_message_id.write({'partner_ids': [(4, pid) for pid in partner_ids]}) |
||||
|
reward_obj.write({'email_send': True}) |
||||
|
|
||||
|
department_ids = fields.Many2many('hr.department', string='Departments') |
@ -0,0 +1,24 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8" ?> |
||||
|
<odoo> |
||||
|
<data> |
||||
|
<template id="reward_warning_letter"> |
||||
|
<t t-call="report.html_container"> |
||||
|
<t t-foreach="docs" t-as="obj"> |
||||
|
<t t-call="report.external_layout"> |
||||
|
<div class="page"> |
||||
|
<t t-raw="obj.letter"/> |
||||
|
</div> |
||||
|
</t> |
||||
|
</t> |
||||
|
</t> |
||||
|
</template> |
||||
|
<report |
||||
|
string="Letter" |
||||
|
id="reward_letter" |
||||
|
model="hr.reward.warning" |
||||
|
report_type="qweb-pdf" |
||||
|
name="hr_reward_warning.reward_warning_letter" |
||||
|
file="hr_reward_warning.reward_warning_letter" |
||||
|
/> |
||||
|
</data> |
||||
|
</odoo> |
|
@ -0,0 +1,9 @@ |
|||||
|
<?xml version="1.0" ?> |
||||
|
<odoo> |
||||
|
<record id="property_rule_reward" model="ir.rule"> |
||||
|
<field name="name">Reward Multi Company</field> |
||||
|
<field name="model_id" ref="model_hr_reward_warning"/> |
||||
|
<field eval="True" name="global"/> |
||||
|
<field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field> |
||||
|
</record> |
||||
|
</odoo> |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 122 KiB |
After Width: | Height: | Size: 221 KiB |
After Width: | Height: | Size: 50 KiB |
After Width: | Height: | Size: 106 KiB |
After Width: | Height: | Size: 36 KiB |
@ -0,0 +1,87 @@ |
|||||
|
<section class="oe_container"> |
||||
|
<div class="oe_row"> |
||||
|
<h2 class="oe_slogan">OpenHRMS</h2> |
||||
|
<h3 class="oe_slogan">Most advanced open source HR management software</h3> |
||||
|
</div> |
||||
|
</section> |
||||
|
|
||||
|
<section class="oe_container"> |
||||
|
<div class="oe_row oe_spaced oe_mt32"> |
||||
|
<div class="oe_span"> |
||||
|
<div class="oe_demo oe_picture oe_screenshot"> |
||||
|
<a href="https://www.openhrms.com/#request-demo"> |
||||
|
<img src="HRMS-BUTTON.png"> |
||||
|
</a> |
||||
|
<div class="oe_demo_footer oe_centeralign">Online Demo</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</section> |
||||
|
|
||||
|
<section class="oe_container"> |
||||
|
<div class="oe_row oe_spaced"> |
||||
|
<h2 class="oe_slogan">OH Official Announcements</h2> |
||||
|
<h3 class="oe_slogan">Manages Official Announcements</h3> |
||||
|
<h4 class="oe_slogan"><a href="https://www.cybrosys.com">Cybrosys Technologies</a> </h4> |
||||
|
</div> |
||||
|
<div class="oe_row oe_spaced" style="padding-left:65px;"> |
||||
|
<h4>Features:</h4> |
||||
|
<div> |
||||
|
<span style="color:green;"> ☑ </span> Managing Official Announcements.<br/> |
||||
|
</div> |
||||
|
</div> |
||||
|
</section> |
||||
|
|
||||
|
<section class="oe_container oe_dark"> |
||||
|
<div class="oe_row oe_spaced"> |
||||
|
<div class="oe_picture"> |
||||
|
<h3 class="oe_slogan">Overview</h3> |
||||
|
<p class="oe_mt32 text-justify" style="text-align: center;"> |
||||
|
This module helps you to manage official announcements. |
||||
|
</p> |
||||
|
</div> |
||||
|
</div> |
||||
|
</section> |
||||
|
|
||||
|
<section class="oe_container"> |
||||
|
<div class="oe_row oe_spaced"> |
||||
|
<div class="oe_span12"> |
||||
|
<div class="oe_demo oe_picture oe_screenshot"> |
||||
|
<img style="border:8px solid white;" src="hr_reward.png"> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</section> |
||||
|
|
||||
|
<div class="row section-content"> |
||||
|
<div class="col-md-6 img-content"> |
||||
|
<h3>Our Odoo Services</h3> |
||||
|
</div> |
||||
|
<div class="bc-span col-md-12"> |
||||
|
<div class="inner-span"> |
||||
|
<a target="_blank" href="https://www.openhrms.com"> |
||||
|
<img class="img-border img-responsive thumbnail" src="cybro-service.png"> |
||||
|
</a> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
<section class="oe_container"> |
||||
|
<h2 class="oe_slogan" style="margin-top:20px;" >Need Any Help?</h2> |
||||
|
<div class="oe_slogan" style="margin-top:10px !important;"> |
||||
|
<div> |
||||
|
<a class="btn btn-primary btn-lg mt8" |
||||
|
style="color: #FFFFFF !important;border-radius: 0;" href="https://www.cybrosys.com"><i |
||||
|
class="fa fa-envelope"></i> Email </a> <a |
||||
|
class="btn btn-primary btn-lg mt8" style="color: #FFFFFF !important;border-radius: 0;" |
||||
|
href="https://www.cybrosys.com/contact/"><i |
||||
|
class="fa fa-phone"></i> Contact Us </a> <a |
||||
|
class="btn btn-primary btn-lg mt8" style="color: #FFFFFF !important;border-radius: 0;" |
||||
|
href="https://www.cybrosys.com/odoo-customization-and-installation/"><i |
||||
|
class="fa fa-check-square"></i> Request Customization </a> |
||||
|
</div> |
||||
|
<br> |
||||
|
<img src="cybro_logo.png" style="width: 190px; margin-bottom: 20px;" class="center-block"> |
||||
|
</div> |
||||
|
</section> |
||||
|
|
@ -0,0 +1,26 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<odoo> |
||||
|
<data> |
||||
|
<record model="ir.ui.view" id="reward_hr_employee_inherit_form_view"> |
||||
|
<field name="name">hr.employee.form.inherit.view</field> |
||||
|
<field name="model">hr.employee</field> |
||||
|
<field name="inherit_id" ref="hr.view_employee_form"/> |
||||
|
<field name="arch" type="xml"> |
||||
|
<div class="oe_button_box" position="inside"> |
||||
|
<button class="oe_stat_button" name="warning_view" type="object" icon="fa-exclamation-triangle"> |
||||
|
<field string="Warnings" name="warning_count" widget="statinfo"/> |
||||
|
</button> |
||||
|
<button class="oe_stat_button" name="reward_view" type="object" icon="fa-thumbs-up"> |
||||
|
<field string="Rewards" name="reward_count" widget="statinfo"/> |
||||
|
</button> |
||||
|
<button class="oe_stat_button" name="announcement_view" type="object" icon="fa-bullhorn"> |
||||
|
<field string="Announcements" name="ann_count" widget="statinfo"/> |
||||
|
</button> |
||||
|
<button class="oe_stat_button" name="letter_view" type="object" icon="fa-envelope"> |
||||
|
<field string="Letters" name="letter_count" widget="statinfo"/> |
||||
|
</button> |
||||
|
</div> |
||||
|
</field> |
||||
|
</record> |
||||
|
</data> |
||||
|
</odoo> |
@ -0,0 +1,197 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<odoo> |
||||
|
<data> |
||||
|
<record id="seq_hr_reward_seq" model="ir.sequence"> |
||||
|
<field name="name">Reward Code</field> |
||||
|
<field name="code">hr.loan.reward</field> |
||||
|
<field name="prefix">RS</field> |
||||
|
<field eval="4" name="padding" /> |
||||
|
</record> |
||||
|
|
||||
|
<record id="seq_hr_warning_seq" model="ir.sequence"> |
||||
|
<field name="name">Warning Code</field> |
||||
|
<field name="code">hr.loan.warning</field> |
||||
|
<field name="prefix">WS</field> |
||||
|
<field eval="4" name="padding" /> |
||||
|
</record> |
||||
|
|
||||
|
<record id="seq_hr_letter_seq" model="ir.sequence"> |
||||
|
<field name="name">Letter Code</field> |
||||
|
<field name="code">hr.loan.letter</field> |
||||
|
<field name="prefix">LS</field> |
||||
|
<field eval="4" name="padding" /> |
||||
|
</record> |
||||
|
|
||||
|
<record id="seq_hr_ga_seq" model="ir.sequence"> |
||||
|
<field name="name">Announcement</field> |
||||
|
<field name="code">hr.loan.announcement</field> |
||||
|
<field name="prefix">GA</field> |
||||
|
<field eval="4" name="padding" /> |
||||
|
</record> |
||||
|
|
||||
|
<record model='ir.ui.view' id='wizard_share_form'> |
||||
|
<field name="name">wizard.send.mail.form</field> |
||||
|
<field name="model">wizard.send.mail</field> |
||||
|
<field name="arch" type="xml"> |
||||
|
<form string="Share Letter"> |
||||
|
<group> |
||||
|
<group> |
||||
|
<field name="department_ids" widget="many2many_tags"/> |
||||
|
</group> |
||||
|
</group> |
||||
|
<footer> |
||||
|
<button name="send_now" string="Send" type="object" class="oe_highlight"/> |
||||
|
or |
||||
|
<button string="Cancel" class="oe_link" special="cancel" /> |
||||
|
</footer> |
||||
|
</form> |
||||
|
</field> |
||||
|
</record> |
||||
|
|
||||
|
<record model='ir.actions.act_window' id='wizard_share_act'> |
||||
|
<field name="name">Share Letter</field> |
||||
|
<field name="res_model">wizard.send.mail</field> |
||||
|
<field name="view_type">form</field> |
||||
|
<field name="view_mode">form</field> |
||||
|
<field name="view_id" ref="wizard_share_form"/> |
||||
|
<field name="target">new</field> |
||||
|
</record> |
||||
|
|
||||
|
<record id="view_hr_reward_warning_form" model="ir.ui.view"> |
||||
|
<field name="name">hr.reward.warning.form</field> |
||||
|
<field name="model">hr.reward.warning</field> |
||||
|
<field name="arch" type="xml"> |
||||
|
<form string="Announcements"> |
||||
|
<header> |
||||
|
<button string="Send For Approval" type="object" name="sent" groups="hr.group_hr_user" |
||||
|
attrs="{'invisible': [('state','not in',('draft'))]}"/> |
||||
|
<button string="Approve" groups="hr.group_hr_manager" type="object" name="approve" |
||||
|
attrs="{'invisible': [('state','not in',('to_approve'))]}"/> |
||||
|
<button string="Refuse" class="btn-primary" groups="hr.group_hr_manager" type="object" |
||||
|
name="reject" states="to_approve"/> |
||||
|
<button string="Set to Draft" type="object" name="set_to_draft" groups="hr.group_hr_user" |
||||
|
attrs="{'invisible': [('state','not in',('rejected'))]}"/> |
||||
|
<button string="Share" type="action" name="%(wizard_share_act)d" groups="hr.group_hr_user" |
||||
|
context="{'reward_id':id,'employee_id':employee_id}" |
||||
|
attrs="{'invisible': ['|',('state','not in',('approved')),('email_send','=',True)]}"/> |
||||
|
<button string="Set to Done" type="object" name="set_to_done" groups="hr.group_hr_user" |
||||
|
attrs="{'invisible': ['|',('state','not in',('approved')), |
||||
|
('hr_type','!=',('letter')), |
||||
|
('is_announcement','=',False)]}"/> |
||||
|
<field name="state" widget="statusbar" statusbar_visible="draft,to_approve,approved,done"/> |
||||
|
</header> |
||||
|
<sheet> |
||||
|
<label for="is_announcement"/> |
||||
|
<div> |
||||
|
<field name="is_announcement"/> |
||||
|
</div> |
||||
|
<h1> |
||||
|
<label for="name"/> |
||||
|
<div> |
||||
|
<field name="name" class="oe_inline" readonly="1"/> |
||||
|
</div> |
||||
|
</h1> |
||||
|
<group> |
||||
|
<label for="reason"/> |
||||
|
<div> |
||||
|
<field name="reason"/> |
||||
|
</div> |
||||
|
</group> |
||||
|
<group> |
||||
|
<group> |
||||
|
<field name="employee_id" attrs="{'invisible': [('is_announcement','=',True)], |
||||
|
'required': [('is_announcement','=',False)]}"/> |
||||
|
<field name="hr_type" attrs="{'invisible': [('is_announcement','=',True)], |
||||
|
'required': [('is_announcement','=',False)]}"/> |
||||
|
<field name="month_of_action" attrs="{'invisible': ['|',('hr_type','=',('letter')), |
||||
|
('is_announcement','=',True)], |
||||
|
'required': [('hr_type','!=',('letter')), |
||||
|
('is_announcement','=',False)]}"/> |
||||
|
<field name="attachment_id" widget="many2many_binary" class="oe_inline"/> |
||||
|
</group> |
||||
|
<group> |
||||
|
<field name="requested_date" readonly="1"/> |
||||
|
<field name="email_send" invisible="1"/> |
||||
|
<field name="amount" attrs="{'invisible': ['|',('hr_type','=',('letter')), |
||||
|
('is_announcement','=',True)]}"/> |
||||
|
<field name="company_id" options="{'no_create': True}" groups="base.group_multi_company"/> |
||||
|
</group> |
||||
|
</group> |
||||
|
<notebook> |
||||
|
<page name="letter" string="Letter"> |
||||
|
<field name="letter"/> |
||||
|
</page> |
||||
|
</notebook> |
||||
|
</sheet> |
||||
|
<div class="oe_chatter"> |
||||
|
<field name="message_follower_ids" widget="mail_followers"/> |
||||
|
<field name="message_ids" widget="mail_thread"/> |
||||
|
</div> |
||||
|
</form> |
||||
|
</field> |
||||
|
</record> |
||||
|
|
||||
|
<record id="view_hr_reward_warning_tree" model="ir.ui.view"> |
||||
|
<field name="name">hr.reward.warning.tree</field> |
||||
|
<field name="model">hr.reward.warning</field> |
||||
|
<field name="arch" type="xml"> |
||||
|
<tree decoration-info="state == 'draft'" colors="grey:state == 'rejected';green:state == 'approved';red:state == 'to_approve';"> |
||||
|
<field name="name"/> |
||||
|
<field name="reason"/> |
||||
|
<field name="employee_id"/> |
||||
|
<field name="hr_type"/> |
||||
|
<field name="month_of_action"/> |
||||
|
<field name="state"/> |
||||
|
</tree> |
||||
|
</field> |
||||
|
</record> |
||||
|
|
||||
|
<record id="view_hr_reward_warning_search" model="ir.ui.view"> |
||||
|
<field name="name">hr.reward.warning.search</field> |
||||
|
<field name="model">hr.reward.warning</field> |
||||
|
<field name="arch" type="xml"> |
||||
|
<search string="Announcements"> |
||||
|
<field name="name"/> |
||||
|
<field name="is_announcement"/> |
||||
|
<field name="reason"/> |
||||
|
<field name="employee_id"/> |
||||
|
<field name="hr_type"/> |
||||
|
<field name="month_of_action"/> |
||||
|
<field name="state"/> |
||||
|
<separator/> |
||||
|
<filter name="approved_rewards" string="Approved Letters" domain="[('state', '=', 'approved')]"/> |
||||
|
<filter name="general_announcements" string="General Announcements" domain="[('is_announcement', '=',True)]"/> |
||||
|
<filter name="warnings" string="Warnings" domain="[('hr_type', '=', 'warning')]"/> |
||||
|
<filter name="letters" string="Letters" domain="[('hr_type', '=', 'letter')]"/> |
||||
|
<filter name="rewards" string="Rewards" domain="[('hr_type', '=', 'reward')]"/> |
||||
|
<group expand="0" string="Group By"> |
||||
|
<filter string="Status" domain="[]" context="{'group_by':'state'}"/> |
||||
|
<filter string="Employee" domain="[]" context="{'group_by':'employee_id'}"/> |
||||
|
<filter string="Type" domain="[]" context="{'group_by':'hr_type'}"/> |
||||
|
<filter string="Month of Action" domain="[]" context="{'group_by':'month_of_action'}"/> |
||||
|
</group> |
||||
|
</search> |
||||
|
</field> |
||||
|
</record> |
||||
|
|
||||
|
<record id="action_hr_reward_warning" model="ir.actions.act_window"> |
||||
|
<field name="name">Announcements</field> |
||||
|
<field name="res_model">hr.reward.warning</field> |
||||
|
<field name="view_type">form</field> |
||||
|
<field name="view_mode">tree,form</field> |
||||
|
<field name="search_view_id" ref="view_hr_reward_warning_search"/> |
||||
|
<field name="help" type="html"> |
||||
|
<p class="oe_view_nocontent_create"> |
||||
|
Click to Create a New Record. |
||||
|
</p> |
||||
|
</field> |
||||
|
</record> |
||||
|
|
||||
|
<menuitem id="hr_reward_warning" parent="hr.menu_hr_root" |
||||
|
groups="hr.group_hr_user,hr.group_hr_manager" |
||||
|
name="Official Announcements" sequence="15"/> |
||||
|
<menuitem action="action_hr_reward_warning" id="hr_reward_warning_sub_menu" parent="hr_reward_warning" |
||||
|
groups="hr.group_hr_user,hr.group_hr_manager" |
||||
|
name="Announcements" sequence="1"/> |
||||
|
</data> |
||||
|
</odoo> |
Loading…
Reference in new issue