Better access rights on hr_holidays_usability
Remove force_send on emails
This commit is contained in:
@@ -1,24 +1,4 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# HR Holidays Usability module for Odoo
|
||||
# Copyright (C) 2015 Akretion (http://www.akretion.com)
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import hr_holidays
|
||||
from . import wizard
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# HR Holidays Usability module for Odoo
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
from openerp import models, fields, api, _
|
||||
from openerp.exceptions import ValidationError
|
||||
from openerp.exceptions import Warning as UserError
|
||||
from datetime import datetime
|
||||
from dateutil.relativedelta import relativedelta
|
||||
import pytz
|
||||
@@ -39,6 +40,11 @@ class HrHolidaysStatus(models.Model):
|
||||
# TODO find proper English translation
|
||||
], string='Vacation Compute Method', required=True,
|
||||
default='worked')
|
||||
add_validation_manager = fields.Boolean(
|
||||
string='Allocation validated by HR Manager',
|
||||
help="If enabled, allocation requests for this leave type "
|
||||
"can be validated only by an HR Manager "
|
||||
"(not possible by an HR Officer).")
|
||||
|
||||
|
||||
class HrEmployee(models.Model):
|
||||
@@ -338,6 +344,34 @@ class HrHolidays(models.Model):
|
||||
obj.number_of_days_temp = days
|
||||
return res
|
||||
|
||||
@api.multi
|
||||
def holidays_validate(self):
|
||||
for holi in self:
|
||||
if holi.user_id == self.env.user:
|
||||
if holi.type == 'remove':
|
||||
raise UserError(_(
|
||||
"You cannot validate your own Leave request '%s'.")
|
||||
% holi.name)
|
||||
elif (
|
||||
holi.type == 'add' and
|
||||
not self.pool['res.users'].has_group(
|
||||
self._cr, self._uid, 'base.group_hr_manager')):
|
||||
raise UserError(_(
|
||||
"You cannot validate your own Allocation "
|
||||
"request '%s'.")
|
||||
% holi.name)
|
||||
if (
|
||||
holi.type == 'add' and
|
||||
holi.holiday_status_id.add_validation_manager and
|
||||
not self.pool['res.users'].has_group(
|
||||
self._cr, self._uid, 'base.group_hr_manager')):
|
||||
raise UserError(_(
|
||||
"Allocation request '%s' has a leave type '%s' that "
|
||||
"can be approved only by an HR Manager.")
|
||||
% (holi.name, holi.holiday_status_id.name))
|
||||
res = super(HrHolidays, self).holidays_validate()
|
||||
return res
|
||||
|
||||
|
||||
class ResCompany(models.Model):
|
||||
_inherit = 'res.company'
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
'dbname': cr.dbname,
|
||||
})
|
||||
template_id=self.pool.get('ir.model.data').get_object_reference(cr, uid, 'hr_holidays_usability', 'email_template_hr_holidays')[1]
|
||||
self.pool.get('email.template').send_mail(cr, uid, template_id, object.id, force_send=True, context=context)</field>
|
||||
self.pool.get('email.template').send_mail(cr, uid, template_id, object.id, context=context)</field>
|
||||
<field name="state">code</field>
|
||||
<field name="type">ir.actions.server</field>
|
||||
<field name="model_id" ref="hr_holidays.model_hr_holidays"/>
|
||||
@@ -23,7 +23,7 @@ self.pool.get('email.template').send_mail(cr, uid, template_id, object.id, force
|
||||
'dbname': cr.dbname,
|
||||
})
|
||||
template_id=self.pool.get('ir.model.data').get_object_reference(cr, uid, 'hr_holidays_usability', 'email_template_hr_holidays')[1]
|
||||
self.pool.get('email.template').send_mail(cr, uid, template_id, object.id, force_send=True, context=context)</field>
|
||||
self.pool.get('email.template').send_mail(cr, uid, template_id, object.id, context=context)</field>
|
||||
<field name="state">code</field>
|
||||
<field name="type">ir.actions.server</field>
|
||||
<field name="model_id" ref="hr_holidays.model_hr_holidays"/>
|
||||
@@ -37,7 +37,7 @@ self.pool.get('email.template').send_mail(cr, uid, template_id, object.id, force
|
||||
'dbname': cr.dbname,
|
||||
})
|
||||
template_id=self.pool.get('ir.model.data').get_object_reference(cr, uid, 'hr_holidays_usability', 'email_template_hr_holidays')[1]
|
||||
self.pool.get('email.template').send_mail(cr, uid, template_id, object.id, force_send=True, context=context)</field>
|
||||
self.pool.get('email.template').send_mail(cr, uid, template_id, object.id, context=context)</field>
|
||||
<field name="state">code</field>
|
||||
<field name="type">ir.actions.server</field>
|
||||
<field name="model_id" ref="hr_holidays.model_hr_holidays"/>
|
||||
@@ -70,10 +70,10 @@ self.pool.get('email.template').send_mail(cr, uid, template_id, object.id, force
|
||||
<div style="font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: #FFF; ">
|
||||
|
||||
% if ctx.get('dbname') and 'prod' not in ctx.get('dbname'):
|
||||
<p>WARNING : THIS IS A TEST E-MAIL sent from a test OpenERP database (${ctx.get('dbname')}). Do not take into account !</p>
|
||||
<p>WARNING : THIS IS A TEST E-MAIL sent from a test Odoo database (${ctx.get('dbname')}). Do not take into account !</p>
|
||||
|
||||
% endif
|
||||
<p>The following ${object.type == 'remove' and 'leave request' or 'ALLOCATION request (i.e. credit of days, not debit !)'} has been ${ctx.get('wkf_tracker') or 'ERROR'} today in OpenERP by ${user.name or ''} :</p>
|
||||
<p>The following ${object.type == 'remove' and 'leave request' or 'ALLOCATION request (i.e. credit of days, not debit !)'} has been ${ctx.get('wkf_tracker') or 'ERROR'} today in Odoo by ${user.name or ''} :</p>
|
||||
|
||||
<ul>
|
||||
<li>Employee : ${object.employee_id.name or ''}</li>
|
||||
@@ -102,7 +102,7 @@ self.pool.get('email.template').send_mail(cr, uid, template_id, object.id, force
|
||||
% endif
|
||||
<p>
|
||||
-- <br/>
|
||||
Automatic e-mail sent by OpenERP. Do not reply.<br/>
|
||||
Automatic e-mail sent by Odoo. Do not reply.<br/>
|
||||
Database : ${ctx.get('dbname')}<br/>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -120,6 +120,9 @@ hr_holidays.edit_holiday_new is used for both leaves and allocation -->
|
||||
<field name="name" position="after">
|
||||
<field name="vacation_compute_method"/>
|
||||
</field>
|
||||
<field name="limit" position="after">
|
||||
<field name="add_validation_manager"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
@@ -1,19 +1,44 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data noupdate="1">
|
||||
<data noupdate="0">
|
||||
|
||||
<!--
|
||||
Employee : only see his holidays
|
||||
Officer = the manager of some employees : see his holidays and the ones of his subordinates
|
||||
Manager = person that administrates the holidays process : can see everything
|
||||
-->
|
||||
|
||||
<record id="hr_holidays_counter_personal_rule" model="ir.rule">
|
||||
<field name="name">Personal Holiday Counters</field>
|
||||
<field name="model_id" ref="model_hr_holidays_employee_counter"/>
|
||||
<field name="domain_force">['|',('employee_id.user_id','=',user.id),('employee_id.user_id','=',False)]</field>
|
||||
<field name="domain_force">[('employee_id.user_id','=',user.id)]</field>
|
||||
<field name="groups" eval="[(4, ref('base.group_user'))]"/>
|
||||
</record>
|
||||
|
||||
<record id="hr_holidays_counter_see_me_and_subordinates" model="ir.rule">
|
||||
<field name="name">My Holiday Counter and Subordinates</field>
|
||||
<field name="model_id" ref="model_hr_holidays_employee_counter"/>
|
||||
<field name="domain_force">['|', ('employee_id.user_id','=',user.id), ('employee_id','child_of',user.employee_ids.ids)]</field>
|
||||
<field name="groups" eval="[(4, ref('base.group_hr_user'))]"/>
|
||||
</record>
|
||||
|
||||
<record id="hr_holidays_counter_see_all" model="ir.rule">
|
||||
<field name="name">All Holiday Counters</field>
|
||||
<field name="model_id" ref="model_hr_holidays_employee_counter"/>
|
||||
<field name="domain_force">[(1,'=',1)]</field>
|
||||
<field name="groups" eval="[(4, ref('base.group_hr_user'))]"/>
|
||||
<field name="groups" eval="[(6, 0, [ref('base.group_hr_manager')])]"/>
|
||||
</record>
|
||||
|
||||
<!-- inherit native ir.rule ; Officer can see the holidays of his subordinates, not all employees -->
|
||||
<record id="hr_holidays.property_rule_holidays_officer" model="ir.rule">
|
||||
<field name="domain_force">['|', ('employee_id.user_id','=',user.id), ('employee_id','child_of',user.employee_ids.ids)]</field>
|
||||
</record>
|
||||
|
||||
<record id="hr_holidays_manager_all" model="ir.rule">
|
||||
<field name="name">HR Manager can see all Holidays</field>
|
||||
<field name="model_id" ref="hr_holidays.model_hr_holidays"/>
|
||||
<field name="domain_force">[(1,'=',1)]</field>
|
||||
<field name="groups" eval="[(4, ref('base.group_hr_manager'))]"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
|
||||
@@ -88,5 +88,6 @@ class HrHolidaysMassAllocation(models.TransientModel):
|
||||
'target': 'current',
|
||||
'domain': [('id', 'in', alloc_hol_ids)],
|
||||
'nodestroy': True,
|
||||
'context': "{'default_type':'add'}",
|
||||
})
|
||||
return action
|
||||
|
||||
Reference in New Issue
Block a user