diff --git a/addons/gamification/data/__init__.py b/addons/gamification/data/__init__.py deleted file mode 100644 index b5649616b2c..00000000000 --- a/addons/gamification/data/__init__.py +++ /dev/null @@ -1,22 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2013 OpenERP SA (). -# -# 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 . -# -############################################################################## - -import goal_definition diff --git a/addons/gamification/data/goal_base.xml b/addons/gamification/data/goal_base.xml index 5da7b86679d..7c23ae81020 100644 --- a/addons/gamification/data/goal_base.xml +++ b/addons/gamification/data/goal_base.xml @@ -122,23 +122,22 @@
Reminder ${object.name}
- -

${object.report_header or ''}

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.

If you have not changed your score yet, you can use the button "The current value is up to date" to indicate so.

]]> - - - Personal Goal Progress + + + Simple Challenge Report Progress - ${object.name} - -

${object.report_header or ''}

+
+ ${object.name} +
+

The following message contains the current progress for the challenge ${object.name}

+% if object.visibility_mode == 'personal': @@ -166,17 +165,8 @@ % endfor -
Goal${line['completeness']} %
]]>
-
- - - Group Goal Progress - - ${object.name} - -

${object.report_header or ''}

- + +% else: % for line in ctx["challenge_lines"]: @@ -209,7 +199,9 @@

% endfor -]]> +% endif + ]]> + diff --git a/addons/gamification/data/goal_definition.py b/addons/gamification/data/goal_definition.py deleted file mode 100644 index e16f2c7b11f..00000000000 --- a/addons/gamification/data/goal_definition.py +++ /dev/null @@ -1,32 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2013 OpenERP SA () -# -# 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 -# -############################################################################## - -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' diff --git a/addons/gamification/models/challenge.py b/addons/gamification/models/challenge.py index 50b949ff03b..12f1b62c6fb 100644 --- a/addons/gamification/models/challenge.py +++ b/addons/gamification/models/challenge.py @@ -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 diff --git a/addons/gamification/views/challenge.xml b/addons/gamification/views/challenge.xml index b10a756f71c..075afcaccfa 100644 --- a/addons/gamification/views/challenge.xml +++ b/addons/gamification/views/challenge.xml @@ -35,7 +35,7 @@
@@ -101,7 +101,7 @@

Depending on the Display mode, reports will be individual or shared.

- + diff --git a/addons/gamification_sale_crm/sale_crm_goals.xml b/addons/gamification_sale_crm/sale_crm_goals.xml index b3dc7e37890..b48cc8a3117 100644 --- a/addons/gamification_sale_crm/sale_crm_goals.xml +++ b/addons/gamification_sale_crm/sale_crm_goals.xml @@ -132,7 +132,6 @@ ranking weekly - The following message contains the current progress of the sale team based on several criterias. The progress is reinitialised each month and shared weekly. @@ -141,7 +140,6 @@ ranking weekly - The following message contains the current progress of the marketing team based on several criterias. The progress is reinitialised each month and shared weekly.