Skip to content

Commit

Permalink
Merge pull request #14 from StefanRijnhart/7.0-subscribe_manager
Browse files Browse the repository at this point in the history
[ADD] Module to send out timesheet notifications and subscribe the employee's manager
  • Loading branch information
Maxime Chambreuil - http://www.savoirfairelinux.com committed Sep 18, 2015
2 parents 2d75fce + 3dd9b55 commit 0ea43cf
Show file tree
Hide file tree
Showing 7 changed files with 218 additions and 0 deletions.
1 change: 1 addition & 0 deletions hr_timesheet_notifications/__init__.py
@@ -0,0 +1 @@
from . import model
46 changes: 46 additions & 0 deletions hr_timesheet_notifications/__openerp__.py
@@ -0,0 +1,46 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# This module copyright (C) 2014 Therp BV (<http://therp.nl>).
#
# 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/>.
#
##############################################################################
{
'name': 'Notify managers and timesheet users of submissions and approvals',
'version': '1.0',
'author': 'Therp BV,Odoo Community Association (OCA)',
'complexity': 'normal',
'website': 'https://github.com/OCA/hr-timesheet',
'category': 'Human Resources',
"license": 'AGPL-3',
'description': """
Module purpose
==============
Subscribe managers to the timesheets of their users automatically. Inform
managers of comments and submissions, while informing users of approvals
and rejections.
Known issues
============
While rejections of timesheets by the manager are logged, on a technical
level this is only a reset to draft status. Therefore,
a rejection cannot be distinguished from a newly created timesheet.
""",
'depends': [
'hr_timesheet_sheet',
],
'data': ['data/mail_message_subtype.xml'],
}
23 changes: 23 additions & 0 deletions hr_timesheet_notifications/data/mail_message_subtype.xml
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="subtype_draft" model="mail.message.subtype">
<field name="name">Timesheet has been set to draft</field>
<field name="res_model">hr_timesheet_sheet.sheet</field>
<field name="default" eval="True"/>
<field name="description">Timesheet has been set to draft</field>
</record>
<record id="subtype_confirm" model="mail.message.subtype">
<field name="name">Timesheet has been submitted</field>
<field name="res_model">hr_timesheet_sheet.sheet</field>
<field name="default" eval="True"/>
<field name="description">Timesheet has been submitted</field>
</record>
<record id="subtype_done" model="mail.message.subtype">
<field name="name">Timesheet has been approved</field>
<field name="res_model">hr_timesheet_sheet.sheet</field>
<field name="default" eval="True"/>
<field name="description">Timesheet has been approved</field>
</record>
</data>
</openerp>
42 changes: 42 additions & 0 deletions hr_timesheet_notifications/i18n/hr_timesheet_notifications.pot
@@ -0,0 +1,42 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * hr_timesheet_notifications
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-05-04 11:06+0000\n"
"PO-Revision-Date: 2014-05-04 11:06+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: hr_timesheet_notifications
#: code:_description:0
#: model:ir.model,name:hr_timesheet_notifications.model_hr_timesheet_sheet_sheet
#, python-format
msgid "Timesheet"
msgstr ""

#. module: hr_timesheet_notifications
#: model:mail.message.subtype,description:hr_timesheet_notifications.subtype_done
#: model:mail.message.subtype,name:hr_timesheet_notifications.subtype_done
msgid "Timesheet has been approved"
msgstr ""

#. module: hr_timesheet_notifications
#: model:mail.message.subtype,description:hr_timesheet_notifications.subtype_draft
#: model:mail.message.subtype,name:hr_timesheet_notifications.subtype_draft
msgid "Timesheet has been set to draft"
msgstr ""

#. module: hr_timesheet_notifications
#: model:mail.message.subtype,description:hr_timesheet_notifications.subtype_confirm
#: model:mail.message.subtype,name:hr_timesheet_notifications.subtype_confirm
msgid "Timesheet has been submitted"
msgstr ""

42 changes: 42 additions & 0 deletions hr_timesheet_notifications/i18n/nl.po
@@ -0,0 +1,42 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * hr_timesheet_notifications
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-05-04 11:06+0000\n"
"PO-Revision-Date: 2014-05-04 11:06+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: hr_timesheet_notifications
#: code:_description:0
#: model:ir.model,name:hr_timesheet_notifications.model_hr_timesheet_sheet_sheet
#, python-format
msgid "Timesheet"
msgstr "Urenstaat"

#. module: hr_timesheet_notifications
#: model:mail.message.subtype,description:hr_timesheet_notifications.subtype_done
#: model:mail.message.subtype,name:hr_timesheet_notifications.subtype_done
msgid "Timesheet has been approved"
msgstr "Urenstaat is goedgekeurd"

#. module: hr_timesheet_notifications
#: model:mail.message.subtype,description:hr_timesheet_notifications.subtype_draft
#: model:mail.message.subtype,name:hr_timesheet_notifications.subtype_draft
msgid "Timesheet has been set to draft"
msgstr "Urenstaat in conceptstatus"

#. module: hr_timesheet_notifications
#: model:mail.message.subtype,description:hr_timesheet_notifications.subtype_confirm
#: model:mail.message.subtype,name:hr_timesheet_notifications.subtype_confirm
msgid "Timesheet has been submitted"
msgstr "Urenstaat is ingediend"

1 change: 1 addition & 0 deletions hr_timesheet_notifications/model/__init__.py
@@ -0,0 +1 @@
from . import hr_timesheet_sheet
63 changes: 63 additions & 0 deletions hr_timesheet_notifications/model/hr_timesheet_sheet.py
@@ -0,0 +1,63 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# This module copyright (C) 2014 Therp BV (<http://therp.nl>).
#
# 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/>.
#
##############################################################################

from openerp.osv import orm


class HrTimesheetSheet(orm.Model):
_inherit = 'hr_timesheet_sheet.sheet'

def create(self, cr, uid, vals, context=None):
"""
Subscribe the manager to their users' sheets
"""
sheet_id = super(HrTimesheetSheet, self).create(
cr, uid, vals, context=context)
sheet = self.browse(cr, uid, sheet_id, context=context)

# Subscribe the manager to comments and sheet confirmation
data_obj = self.pool['ir.model.data']
subtype_ids = [
data_obj.get_object_reference(cr, uid, 'mail', 'mt_comment')[1],
data_obj.get_object_reference(
cr, uid, 'hr_timesheet_notifications', 'subtype_confirm')[1],
]

if (sheet.employee_id.parent_id and
sheet.employee_id.parent_id.user_id):
sheet.message_subscribe_users(
subtype_ids=subtype_ids,
user_ids=[sheet.employee_id.parent_id.user_id.id])
return sheet_id

_track = {
'state': {
'hr_timesheet_notifications.subtype_draft': (
lambda self, cr, uid, obj, context=None:
obj['state'] == 'draft'),
'hr_timesheet_notifications.subtype_confirm': (
lambda self, cr, uid, obj, context=None:
obj['state'] == 'confirm'),
'hr_timesheet_notifications.subtype_done': (
lambda self, cr, uid, obj, context=None:
obj['state'] == 'done'),
},
}

0 comments on commit 0ea43cf

Please sign in to comment.