<header>
<strong>Reminder ${object.name}</strong>
</header>
-
- <p class="oe_grey">${object.report_header or ''}</p>
<p>You have not updated your progress for the goal ${object.definition_id.name} (currently reached at ${object.completeness}%) for at least ${object.remind_update_delay} days. Do not forget to do it.</p>
<p>If you have not changed your score yet, you can use the button "The current value is up to date" to indicate so.</p>
]]></field>
</record>
-
- <record id="email_template_goal_progress_perso" model="email.template">
- <field name="name">Personal Goal Progress</field>
+
+ <record id="simple_report_template" model="email.template">
+ <field name="name">Simple Challenge Report Progress</field>
<field name="body_html"><![CDATA[
- <header>
- <strong>${object.name}</strong>
- </header>
- <p class="oe_grey">${object.report_header or ''}</p>
+<header>
+ <strong>${object.name}</strong>
+</header>
+<p class="oe_grey">The following message contains the current progress for the challenge ${object.name}</p>
+% if object.visibility_mode == 'personal':
<table width="100%" border="1">
<tr>
<th>Goal</th>
<td>${line['completeness']} %</td>
</tr>
% endfor
- </table>]]></field>
- </record>
-
- <record id="email_template_goal_progress_group" model="email.template">
- <field name="name">Group Goal Progress</field>
- <field name="body_html"><![CDATA[
- <header>
- <strong>${object.name}</strong>
- </header>
- <p class="oe_grey">${object.report_header or ''}</p>
-
+ </table>
+% else:
% for line in ctx["challenge_lines"]:
<table width="100%" border="1">
<tr>
<br/><br/>
% endfor
-]]></field>
+% endif
+ ]]></field>
</record>
+
</data>
</openerp>
+++ /dev/null
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2013 OpenERP SA (<http://www.openerp.com>)
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU 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 General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>
-#
-##############################################################################
-
-from openerp.osv import osv
-
-
-class gamification_goal_definition_data(osv.Model):
- """Goal definition data
-
- Methods for more complex goals not possible with the 'sum' and 'count' mode.
- Each method should return the value that will be set in the 'current' field
- of a user's goal. The return definition must be a float or integer.
- """
- _inherit = 'gamification.goal.definition'
res[challenge.id] = False
return res
+
def _get_categories(self, cr, uid, context=None):
- return [
- ('hr', 'Human Ressources / Engagement'),
- ('other', 'Settings / Gamification Tools'),
- ]
+ return [
+ ('hr', 'Human Ressources / Engagement'),
+ ('other', 'Settings / Gamification Tools'),
+ ]
+
+ def _get_report_template(self, cr, uid, context=None):
+ try:
+ return self.pool.get('ir.model.data').get_object_reference(cr, uid, 'gamification', 'simple_report_template')[1]
+ except ValueError:
+ return False
_order = 'end_date, start_date, name, id'
_columns = {
('ranking', 'Leader Board (Group Ranking)'),
],
string="Display Mode", required=True),
+
'report_message_frequency': fields.selection([
('never', 'Never'),
('onchange', 'On change'),
'report_message_group_id': fields.many2one('mail.group',
string='Send a copy to',
help='Group that will receive a copy of the report in addition to the user'),
- 'report_header': fields.text('Report Header'),
+ 'report_template_id': fields.many2one('email.template', string="Report Template", required=True),
'remind_update_delay': fields.integer('Non-updated manual goals will be reminded after',
help="Never reminded if no value or zero is specified."),
'last_report_date': fields.date('Last Report Date'),
'manager_id': lambda s, cr, uid, c: uid,
'category': 'hr',
'reward_failure': False,
+ 'report_template_id': lambda s, *a, **k: s._get_report_template(*a, **k),
}
vals['user_ids'] = []
vals['user_ids'] += [(4, user.id) for user in new_group.users]
- print vals.get('state')
if vals.get('state') == 'inprogress':
if not vals.get('autojoin_group_id'):
"""
if context is None:
context = {}
- # template_env = TemplateHelper()
+
temp_obj = self.pool.get('email.template')
ctx = context.copy()
if challenge.visibility_mode == 'ranking':
lines_boards = self._get_serialized_challenge_lines(cr, uid, challenge, user_id=False, restrict_goal_ids=subset_goal_ids, restrict_top=False, context=context)
ctx.update({'challenge_lines': lines_boards})
- template_id = self.pool.get('ir.model.data').get_object(cr, uid, 'gamification', 'email_template_goal_progress_group', context)
- body_html = temp_obj.render_template(cr, uid, template_id.body_html, 'gamification.challenge', challenge.id, context=ctx)
-
- # body_html = template_env.get_template('group_progress.mako').render({'object': challenge, 'lines_boards': lines_boards, 'uid': uid})
+ body_html = temp_obj.render_template(cr, uid, challenge.report_template_id.body_html, 'gamification.challenge', challenge.id, context=ctx)
# send to every follower of the challenge
self.message_post(cr, uid, challenge.id,
continue
ctx.update({'challenge_lines': goals})
- template_id = self.pool.get('ir.model.data').get_object(cr, uid, 'gamification', 'email_template_goal_progress_perso', context)
- body_html = temp_obj.render_template(cr, user.id, template_id.body_html, 'gamification.challenge', challenge.id, context=ctx)
+ body_html = temp_obj.render_template(cr, user.id, challenge.report_template_id.body_html, 'gamification.challenge', challenge.id, context=ctx)
+
# send message only to users, not on the challenge
self.message_post(cr, uid, 0,
body=body_html,
return self.write(cr, uid, challenge_ids, {'invited_user_ids': (3, user_id)}, context=context)
def reply_challenge_wizard(self, cr, uid, challenge_id, context=None):
- mod_obj = self.pool.get('ir.model.data')
- act_obj = self.pool.get('ir.actions.act_window')
- result = mod_obj.get_object_reference(cr, uid, 'gamification', 'challenge_wizard')
+ result = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'gamification', 'challenge_wizard')
id = result and result[1] or False
- result = act_obj.read(cr, uid, [id], context=context)[0]
+ result = self.pool.get('ir.actions.act_window').read(cr, uid, [id], context=context)[0]
result['res_id'] = challenge_id
return result