Merge lp:~therp-nl/therp-addons/7.0-hr_timesheet_subscribe_manager into lp:~therp-nl/therp-addons/7.0

Proposed by Stefan Rijnhart (Opener)
Status: Work in progress
Proposed branch: lp:~therp-nl/therp-addons/7.0-hr_timesheet_subscribe_manager
Merge into: lp:~therp-nl/therp-addons/7.0
Diff against target: 253 lines (+215/-0)
7 files modified
hr_timesheet_notifications/__init__.py (+1/-0)
hr_timesheet_notifications/__openerp__.py (+44/-0)
hr_timesheet_notifications/data/mail_message_subtype.xml (+23/-0)
hr_timesheet_notifications/i18n/hr_timesheet_notifications.pot (+42/-0)
hr_timesheet_notifications/i18n/nl.po (+42/-0)
hr_timesheet_notifications/model/__init__.py (+1/-0)
hr_timesheet_notifications/model/hr_timesheet_sheet.py (+62/-0)
To merge this branch: bzr merge lp:~therp-nl/therp-addons/7.0-hr_timesheet_subscribe_manager
Reviewer Review Type Date Requested Status
Therp Pending
Review via email: mp+218213@code.launchpad.net
To post a comment you must log in.
104. By Stefan Rijnhart (Opener)

[FIX] Actually take the user id to subscribe

105. By Stefan Rijnhart (Opener)

[RFR] Implement message subtypes for timesheets

106. By Stefan Rijnhart (Opener)

[IMP] Module description

107. By Stefan Rijnhart (Opener)

[RFR] Translation

Unmerged revisions

107. By Stefan Rijnhart (Opener)

[RFR] Translation

106. By Stefan Rijnhart (Opener)

[IMP] Module description

105. By Stefan Rijnhart (Opener)

[RFR] Implement message subtypes for timesheets

104. By Stefan Rijnhart (Opener)

[FIX] Actually take the user id to subscribe

103. By Stefan Rijnhart (Opener)

[ADD] Subscribe managers to their users' timesheets

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'hr_timesheet_notifications'
2=== added file 'hr_timesheet_notifications/__init__.py'
3--- hr_timesheet_notifications/__init__.py 1970-01-01 00:00:00 +0000
4+++ hr_timesheet_notifications/__init__.py 2014-05-04 11:32:48 +0000
5@@ -0,0 +1,1 @@
6+from . import model
7
8=== added file 'hr_timesheet_notifications/__openerp__.py'
9--- hr_timesheet_notifications/__openerp__.py 1970-01-01 00:00:00 +0000
10+++ hr_timesheet_notifications/__openerp__.py 2014-05-04 11:32:48 +0000
11@@ -0,0 +1,44 @@
12+# -*- coding: utf-8 -*-
13+##############################################################################
14+#
15+# OpenERP, Open Source Management Solution
16+# This module copyright (C) 2014 Therp BV (<http://therp.nl>).
17+#
18+# This program is free software: you can redistribute it and/or modify
19+# it under the terms of the GNU Affero General Public License as
20+# published by the Free Software Foundation, either version 3 of the
21+# License, or (at your option) any later version.
22+#
23+# This program is distributed in the hope that it will be useful,
24+# but WITHOUT ANY WARRANTY; without even the implied warranty of
25+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26+# GNU Affero General Public License for more details.
27+#
28+# You should have received a copy of the GNU Affero General Public License
29+# along with this program. If not, see <http://www.gnu.org/licenses/>.
30+#
31+##############################################################################
32+{
33+ 'name': 'Notify managers and timesheet users of submissions and approvals',
34+ 'version': '1.0',
35+ 'author': 'Therp BV',
36+ 'complexity': 'normal',
37+ 'category': 'Human Resources',
38+ 'description': """
39+Module purpose
40+==============
41+Subscribe managers to the timesheets of their users automatically. Inform
42+managers of comments and submissions, while informing users of approvals
43+and rejections.
44+
45+Known issues
46+============
47+While rejections of timesheets by the manager are logged, on a technical
48+level this is only a reset to draft status. Therefore,
49+a rejection cannot be distinguished from a newly created timesheet.
50+ """,
51+ 'depends': [
52+ 'hr_timesheet_sheet',
53+ ],
54+ 'data': ['data/mail_message_subtype.xml'],
55+}
56
57=== added directory 'hr_timesheet_notifications/data'
58=== added file 'hr_timesheet_notifications/data/mail_message_subtype.xml'
59--- hr_timesheet_notifications/data/mail_message_subtype.xml 1970-01-01 00:00:00 +0000
60+++ hr_timesheet_notifications/data/mail_message_subtype.xml 2014-05-04 11:32:48 +0000
61@@ -0,0 +1,23 @@
62+<?xml version="1.0" encoding="utf-8"?>
63+<openerp>
64+ <data>
65+ <record id="subtype_draft" model="mail.message.subtype">
66+ <field name="name">Timesheet has been set to draft</field>
67+ <field name="res_model">hr_timesheet_sheet.sheet</field>
68+ <field name="default" eval="True"/>
69+ <field name="description">Timesheet has been set to draft</field>
70+ </record>
71+ <record id="subtype_confirm" model="mail.message.subtype">
72+ <field name="name">Timesheet has been submitted</field>
73+ <field name="res_model">hr_timesheet_sheet.sheet</field>
74+ <field name="default" eval="True"/>
75+ <field name="description">Timesheet has been submitted</field>
76+ </record>
77+ <record id="subtype_done" model="mail.message.subtype">
78+ <field name="name">Timesheet has been approved</field>
79+ <field name="res_model">hr_timesheet_sheet.sheet</field>
80+ <field name="default" eval="True"/>
81+ <field name="description">Timesheet has been approved</field>
82+ </record>
83+ </data>
84+</openerp>
85
86=== added directory 'hr_timesheet_notifications/i18n'
87=== added file 'hr_timesheet_notifications/i18n/hr_timesheet_notifications.pot'
88--- hr_timesheet_notifications/i18n/hr_timesheet_notifications.pot 1970-01-01 00:00:00 +0000
89+++ hr_timesheet_notifications/i18n/hr_timesheet_notifications.pot 2014-05-04 11:32:48 +0000
90@@ -0,0 +1,42 @@
91+# Translation of OpenERP Server.
92+# This file contains the translation of the following modules:
93+# * hr_timesheet_notifications
94+#
95+msgid ""
96+msgstr ""
97+"Project-Id-Version: OpenERP Server 7.0\n"
98+"Report-Msgid-Bugs-To: \n"
99+"POT-Creation-Date: 2014-05-04 11:06+0000\n"
100+"PO-Revision-Date: 2014-05-04 11:06+0000\n"
101+"Last-Translator: <>\n"
102+"Language-Team: \n"
103+"MIME-Version: 1.0\n"
104+"Content-Type: text/plain; charset=UTF-8\n"
105+"Content-Transfer-Encoding: \n"
106+"Plural-Forms: \n"
107+
108+#. module: hr_timesheet_notifications
109+#: code:_description:0
110+#: model:ir.model,name:hr_timesheet_notifications.model_hr_timesheet_sheet_sheet
111+#, python-format
112+msgid "Timesheet"
113+msgstr ""
114+
115+#. module: hr_timesheet_notifications
116+#: model:mail.message.subtype,description:hr_timesheet_notifications.subtype_done
117+#: model:mail.message.subtype,name:hr_timesheet_notifications.subtype_done
118+msgid "Timesheet has been approved"
119+msgstr ""
120+
121+#. module: hr_timesheet_notifications
122+#: model:mail.message.subtype,description:hr_timesheet_notifications.subtype_draft
123+#: model:mail.message.subtype,name:hr_timesheet_notifications.subtype_draft
124+msgid "Timesheet has been set to draft"
125+msgstr ""
126+
127+#. module: hr_timesheet_notifications
128+#: model:mail.message.subtype,description:hr_timesheet_notifications.subtype_confirm
129+#: model:mail.message.subtype,name:hr_timesheet_notifications.subtype_confirm
130+msgid "Timesheet has been submitted"
131+msgstr ""
132+
133
134=== added file 'hr_timesheet_notifications/i18n/nl.po'
135--- hr_timesheet_notifications/i18n/nl.po 1970-01-01 00:00:00 +0000
136+++ hr_timesheet_notifications/i18n/nl.po 2014-05-04 11:32:48 +0000
137@@ -0,0 +1,42 @@
138+# Translation of OpenERP Server.
139+# This file contains the translation of the following modules:
140+# * hr_timesheet_notifications
141+#
142+msgid ""
143+msgstr ""
144+"Project-Id-Version: OpenERP Server 7.0\n"
145+"Report-Msgid-Bugs-To: \n"
146+"POT-Creation-Date: 2014-05-04 11:06+0000\n"
147+"PO-Revision-Date: 2014-05-04 11:06+0000\n"
148+"Last-Translator: <>\n"
149+"Language-Team: \n"
150+"MIME-Version: 1.0\n"
151+"Content-Type: text/plain; charset=UTF-8\n"
152+"Content-Transfer-Encoding: \n"
153+"Plural-Forms: \n"
154+
155+#. module: hr_timesheet_notifications
156+#: code:_description:0
157+#: model:ir.model,name:hr_timesheet_notifications.model_hr_timesheet_sheet_sheet
158+#, python-format
159+msgid "Timesheet"
160+msgstr "Urenstaat"
161+
162+#. module: hr_timesheet_notifications
163+#: model:mail.message.subtype,description:hr_timesheet_notifications.subtype_done
164+#: model:mail.message.subtype,name:hr_timesheet_notifications.subtype_done
165+msgid "Timesheet has been approved"
166+msgstr "Urenstaat is goedgekeurd"
167+
168+#. module: hr_timesheet_notifications
169+#: model:mail.message.subtype,description:hr_timesheet_notifications.subtype_draft
170+#: model:mail.message.subtype,name:hr_timesheet_notifications.subtype_draft
171+msgid "Timesheet has been set to draft"
172+msgstr "Urenstaat in conceptstatus"
173+
174+#. module: hr_timesheet_notifications
175+#: model:mail.message.subtype,description:hr_timesheet_notifications.subtype_confirm
176+#: model:mail.message.subtype,name:hr_timesheet_notifications.subtype_confirm
177+msgid "Timesheet has been submitted"
178+msgstr "Urenstaat is ingediend"
179+
180
181=== added directory 'hr_timesheet_notifications/model'
182=== added file 'hr_timesheet_notifications/model/__init__.py'
183--- hr_timesheet_notifications/model/__init__.py 1970-01-01 00:00:00 +0000
184+++ hr_timesheet_notifications/model/__init__.py 2014-05-04 11:32:48 +0000
185@@ -0,0 +1,1 @@
186+from . import hr_timesheet_sheet
187
188=== added file 'hr_timesheet_notifications/model/hr_timesheet_sheet.py'
189--- hr_timesheet_notifications/model/hr_timesheet_sheet.py 1970-01-01 00:00:00 +0000
190+++ hr_timesheet_notifications/model/hr_timesheet_sheet.py 2014-05-04 11:32:48 +0000
191@@ -0,0 +1,62 @@
192+# -*- coding: utf-8 -*-
193+##############################################################################
194+#
195+# OpenERP, Open Source Management Solution
196+# This module copyright (C) 2014 Therp BV (<http://therp.nl>).
197+#
198+# This program is free software: you can redistribute it and/or modify
199+# it under the terms of the GNU Affero General Public License as
200+# published by the Free Software Foundation, either version 3 of the
201+# License, or (at your option) any later version.
202+#
203+# This program is distributed in the hope that it will be useful,
204+# but WITHOUT ANY WARRANTY; without even the implied warranty of
205+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
206+# GNU Affero General Public License for more details.
207+#
208+# You should have received a copy of the GNU Affero General Public License
209+# along with this program. If not, see <http://www.gnu.org/licenses/>.
210+#
211+##############################################################################
212+
213+from openerp.osv import orm
214+
215+
216+class HrTimesheetSheet(orm.Model):
217+ _inherit = 'hr_timesheet_sheet.sheet'
218+
219+ def create(self, cr, uid, vals, context=None):
220+ """
221+ Subscribe the manager to their users' sheets
222+ """
223+ sheet_id = super(HrTimesheetSheet, self).create(
224+ cr, uid, vals, context=context)
225+ sheet = self.browse(cr, uid, sheet_id, context=context)
226+
227+ # Subscribe the manager to comments and sheet confirmation
228+ data_obj = self.pool['ir.model.data']
229+ subtype_ids = [
230+ data_obj.get_object_reference(cr, uid, 'mail', 'mt_comment')[1],
231+ data_obj.get_object_reference(
232+ cr, uid, 'hr_timesheet_notifications', 'subtype_confirm')[1],
233+ ]
234+
235+ if sheet.employee_id.parent_id.user_id:
236+ sheet.message_subscribe_users(
237+ subtype_ids=subtype_ids,
238+ user_ids=[sheet.employee_id.parent_id.user_id.id])
239+ return sheet_id
240+
241+ _track = {
242+ 'state': {
243+ 'hr_timesheet_notifications.subtype_draft': (
244+ lambda self, cr, uid, obj, context=None:
245+ obj['state'] == 'draft'),
246+ 'hr_timesheet_notifications.subtype_confirm': (
247+ lambda self, cr, uid, obj, context=None:
248+ obj['state'] == 'confirm'),
249+ 'hr_timesheet_notifications.subtype_done': (
250+ lambda self, cr, uid, obj, context=None:
251+ obj['state'] == 'done'),
252+ },
253+ }

Subscribers

People subscribed via source and target branches

to all changes: