[REF] gamification: use m2o to email.template for report progress, create new field report_template_id, cleaning code
bzr revid: mat@openerp.com-20131224144514-lmbhw88nj7aa3r8i
This commit is contained in:
parent
25117ca97f
commit
be7bc54edc
|
@ -1,22 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2013 OpenERP SA (<http://openerp.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/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import goal_definition
|
|
@ -122,23 +122,22 @@
|
|||
<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>
|
||||
|
@ -166,17 +165,8 @@
|
|||
<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>
|
||||
|
@ -209,7 +199,9 @@
|
|||
<br/><br/>
|
||||
|
||||
% endfor
|
||||
]]></field>
|
||||
% endif
|
||||
]]></field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
# -*- 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'
|
|
@ -102,11 +102,18 @@ class gamification_challenge(osv.Model):
|
|||
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 = {
|
||||
|
@ -163,6 +170,7 @@ class gamification_challenge(osv.Model):
|
|||
('ranking', 'Leader Board (Group Ranking)'),
|
||||
],
|
||||
string="Display Mode", required=True),
|
||||
|
||||
'report_message_frequency': fields.selection([
|
||||
('never', 'Never'),
|
||||
('onchange', 'On change'),
|
||||
|
@ -175,7 +183,7 @@ class gamification_challenge(osv.Model):
|
|||
'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'),
|
||||
|
@ -196,6 +204,7 @@ class gamification_challenge(osv.Model):
|
|||
'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),
|
||||
}
|
||||
|
||||
|
||||
|
@ -232,7 +241,6 @@ class gamification_challenge(osv.Model):
|
|||
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'):
|
||||
|
@ -575,17 +583,14 @@ class gamification_challenge(osv.Model):
|
|||
"""
|
||||
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,
|
||||
|
@ -606,8 +611,8 @@ class gamification_challenge(osv.Model):
|
|||
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,
|
||||
|
@ -640,11 +645,9 @@ class gamification_challenge(osv.Model):
|
|||
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
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
<form string="Goal definitions" version="7.0">
|
||||
<header>
|
||||
<button string="Refresh Challenge" type="object" name="action_check" states="inprogress"/>
|
||||
<button string="Report Progress" type="object" name="action_report_progress" states="inprogress,done" groups="base.group_no_one"/>
|
||||
<button string="Send Report" type="object" name="action_report_progress" states="inprogress,done" groups="base.group_no_one"/>
|
||||
<field name="state" widget="statusbar" clickable="True"/>
|
||||
</header>
|
||||
<sheet>
|
||||
|
@ -101,7 +101,7 @@
|
|||
<p>Depending on the Display mode, reports will be individual or shared.</p>
|
||||
</div>
|
||||
<field name="report_message_frequency" />
|
||||
<field name="report_header" placeholder="e.g. The following message contains the current progress of the sale team..." attrs="{'invisible': [('report_message_frequency','=','never')]}" />
|
||||
<field name="report_template_id" attrs="{'invisible': [('report_message_frequency','=','never')]}" />
|
||||
<field name="report_message_group_id" attrs="{'invisible': [('report_message_frequency','=','never')]}" />
|
||||
</group>
|
||||
<group string="Reminders for Manual Goals">
|
||||
|
|
|
@ -132,7 +132,6 @@
|
|||
<field name="visibility_mode">ranking</field>
|
||||
<field name="autojoin_group_id" eval="ref('base.group_sale_salesman')" />
|
||||
<field name="report_message_frequency">weekly</field>
|
||||
<field name="report_header">The following message contains the current progress of the sale team based on several criterias. The progress is reinitialised each month and shared weekly.</field>
|
||||
</record>
|
||||
|
||||
<record model="gamification.challenge" id="challenge_crm_marketing">
|
||||
|
@ -141,7 +140,6 @@
|
|||
<field name="visibility_mode">ranking</field>
|
||||
<field name="autojoin_group_id" eval="ref('base.group_sale_salesman')" />
|
||||
<field name="report_message_frequency">weekly</field>
|
||||
<field name="report_header">The following message contains the current progress of the marketing team based on several criterias. The progress is reinitialised each month and shared weekly.</field>
|
||||
</record>
|
||||
|
||||
<!-- lines -->
|
||||
|
|
Loading…
Reference in New Issue