From c9464672dedca5697810f67235c8f07b60fffd06 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Thu, 14 Feb 2013 09:20:38 +0100 Subject: [PATCH 001/521] [ADD] inital hr_goal files bzr revid: mat@openerp.com-20130214082038-4b62m2rlugszfpiv --- addons/hr_goal/__init__.py | 1 + addons/hr_goal/__openerp__.py | 39 +++++++++ addons/hr_goal/goal.py | 129 +++++++++++++++++++++++++++++ addons/hr_goal/view/criteria.xml | 17 ++++ addons/hr_goal/view/definition.xml | 15 ++++ addons/hr_goal/view/instance.xml | 13 +++ addons/hr_goal/view/preset.xml | 13 +++ 7 files changed, 227 insertions(+) create mode 100644 addons/hr_goal/__init__.py create mode 100644 addons/hr_goal/__openerp__.py create mode 100644 addons/hr_goal/goal.py create mode 100644 addons/hr_goal/view/criteria.xml create mode 100644 addons/hr_goal/view/definition.xml create mode 100644 addons/hr_goal/view/instance.xml create mode 100644 addons/hr_goal/view/preset.xml diff --git a/addons/hr_goal/__init__.py b/addons/hr_goal/__init__.py new file mode 100644 index 00000000000..7c0f769d0b0 --- /dev/null +++ b/addons/hr_goal/__init__.py @@ -0,0 +1 @@ +import goal \ No newline at end of file diff --git a/addons/hr_goal/__openerp__.py b/addons/hr_goal/__openerp__.py new file mode 100644 index 00000000000..187fb15b121 --- /dev/null +++ b/addons/hr_goal/__openerp__.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2013 Tiny SPRL (). +# +# 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 . +# +############################################################################## +{ + 'name': 'Goal', + 'version': '1.0', + 'author': 'OpenERP SA', + 'category': 'Human Resources', + 'depends': ['base', 'hr'], + 'description': """HR Goal definition + +Defined goals to users""", + + 'data': [ + 'view/criteria.xml', + 'view/definition.xml', + 'view/instance.xml', + 'view/preset.xml', + ], + 'installable': True, + 'application': True, +} diff --git a/addons/hr_goal/goal.py b/addons/hr_goal/goal.py new file mode 100644 index 00000000000..19551b2c24c --- /dev/null +++ b/addons/hr_goal/goal.py @@ -0,0 +1,129 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2013 Tiny SPRL (). +# +# 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 . +# +############################################################################## + +from openerp.osv import fields, osv + +from datetime import date + +class hr_goal_criteria(osv.Model): + """Goal criteria definition + + A criteria defining a way to set an objective and evaluate it + Each module wanting to be able to set goals to the users needs to create + a new goal_criteria + """ + _name = 'hr.goal.criteria' + _description = 'Goal criteria' + + def get_evaluated_field_value(self, cr, user, ids, vals, context=None): + """Return the type of the 'evaluated_field' field""" + for item in self.browse(cr, user, ids, context=context): + return item.evaluated_field.ttype + + _columns = { + 'name': fields.char('Name'), + 'description': fields.char('Description'), + 'evaluated_field': fields.many2one('ir.model.fields', + string='Evaluated field'), + } + +class hr_goal(osv.Model): + """Goal instance for a user + + An individual goal for a user on a specified time period + """ + + _name = 'hr.goal.instance' + _description = 'Goal instance' + + _columns = { + 'criteria_id' : fields.many2one('hr.goal.criteria', string='Criteria'), + 'user_id' : fields.many2one('res.users', string='User'), + 'start_date' : fields.date('Start date'), + 'end_date' : fields.date('End date'), + 'to_reach' : fields.char('To reach'), + 'current' : fields.char('Current'), + } + + def _compute_default_end_date(self, cr, uid, ids, field_name, arg, + context=None): + hr_goal = self.browse(cr, uid, ids, context) + if hr_goal.start_date: + return hr_goal.start_date + datetime.timedelta(days=1) + else: + return fields.date.today() + datetime.timedelta(days=1) + + _defaults = { + 'start_date': fields.date.today, + 'end_date': _compute_default_end_date, + 'current': "", + } + + + +class hr_goal_definition(osv.Model): + """Goal definition + + Predifined goal for 'hr_goal_preset' + """ + + _name = 'hr.goal.definition' + _description = 'Goal definition' + + _columns = { + 'criteria_id' : fields.many2one('hr.goal.criteria', + string='Criteria'), + 'default_to_reach' : fields.char('Default value to reach'), + } + + +class hr_goal_preset(osv.Model): + """Goal preset + + Set of predifined goals to be able to automate goal settings or + quickly apply several goals manually + + If both 'group_id' and 'period' are defined, the set will be assigned to the + group for each period (eg: every 1st of each month if 'monthly' is selected) + """ + + _name = 'hr.goal.preset' + _description = 'Goal preset' + + _columns = { + 'name' : fields.char('Set name'), + 'definition_id' : fields.many2many('hr.goal.definition', + string='Definition'), + 'group_id' : fields.many2one('res.groups', string='Group'), + 'period' : fields.selection( + ( + ('n','No automatic assigment'), + ('d','Daily'), + ('m','Monthly'), + ('y', 'Yearly') + ), + string='Period', + description='Period of automatic goal assigment, ignored if no group is selected'), + } + + _defaults = { + 'period': 'n', + } \ No newline at end of file diff --git a/addons/hr_goal/view/criteria.xml b/addons/hr_goal/view/criteria.xml new file mode 100644 index 00000000000..8e47f656c10 --- /dev/null +++ b/addons/hr_goal/view/criteria.xml @@ -0,0 +1,17 @@ + + + + + Criterias + hr.goal.criteria + tree,form + + + + + + + + + \ No newline at end of file diff --git a/addons/hr_goal/view/definition.xml b/addons/hr_goal/view/definition.xml new file mode 100644 index 00000000000..47241f6710b --- /dev/null +++ b/addons/hr_goal/view/definition.xml @@ -0,0 +1,15 @@ + + + + + Goal definitions + hr.goal.definition + tree,form + + + + + + + \ No newline at end of file diff --git a/addons/hr_goal/view/instance.xml b/addons/hr_goal/view/instance.xml new file mode 100644 index 00000000000..d89f2f1ca22 --- /dev/null +++ b/addons/hr_goal/view/instance.xml @@ -0,0 +1,13 @@ + + + + + Goals + hr.goal.instance + tree,form + + + + + \ No newline at end of file diff --git a/addons/hr_goal/view/preset.xml b/addons/hr_goal/view/preset.xml new file mode 100644 index 00000000000..270149b812e --- /dev/null +++ b/addons/hr_goal/view/preset.xml @@ -0,0 +1,13 @@ + + + + + Presets + hr.goal.preset + tree,form + + + + + \ No newline at end of file From 13bef9108d6781a7936aa79ad88fe030a319ee0e Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Thu, 14 Feb 2013 10:21:51 +0100 Subject: [PATCH 002/521] [IMP] usage of float instead of char for goals bzr revid: mat@openerp.com-20130214092151-5vn2hki2td0lirc6 --- addons/hr_goal/goal.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/addons/hr_goal/goal.py b/addons/hr_goal/goal.py index 19551b2c24c..0fd5da3a16a 100644 --- a/addons/hr_goal/goal.py +++ b/addons/hr_goal/goal.py @@ -33,11 +33,6 @@ class hr_goal_criteria(osv.Model): _name = 'hr.goal.criteria' _description = 'Goal criteria' - def get_evaluated_field_value(self, cr, user, ids, vals, context=None): - """Return the type of the 'evaluated_field' field""" - for item in self.browse(cr, user, ids, context=context): - return item.evaluated_field.ttype - _columns = { 'name': fields.char('Name'), 'description': fields.char('Description'), @@ -59,8 +54,8 @@ class hr_goal(osv.Model): 'user_id' : fields.many2one('res.users', string='User'), 'start_date' : fields.date('Start date'), 'end_date' : fields.date('End date'), - 'to_reach' : fields.char('To reach'), - 'current' : fields.char('Current'), + 'to_reach' : fields.float('To reach'), + 'current' : fields.float('Current'), } def _compute_default_end_date(self, cr, uid, ids, field_name, arg, @@ -91,7 +86,7 @@ class hr_goal_definition(osv.Model): _columns = { 'criteria_id' : fields.many2one('hr.goal.criteria', string='Criteria'), - 'default_to_reach' : fields.char('Default value to reach'), + 'default_to_reach' : fields.float('Default value to reach'), } @@ -126,4 +121,4 @@ class hr_goal_preset(osv.Model): _defaults = { 'period': 'n', - } \ No newline at end of file + } From 759bd008b9e72b6d9cf03adc654da45bbd92c65d Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Thu, 14 Feb 2013 18:07:36 +0100 Subject: [PATCH 003/521] [IMP] match new specifications of gamification module bzr revid: mat@openerp.com-20130214170736-rzzji6pbk24i3u25 --- addons/hr_goal/__openerp__.py | 16 +-- addons/hr_goal/goal.py | 220 ++++++++++++++++++++----------- addons/hr_goal/view/criteria.xml | 17 --- addons/hr_goal/view/type.xml | 16 +++ 4 files changed, 164 insertions(+), 105 deletions(-) delete mode 100644 addons/hr_goal/view/criteria.xml create mode 100644 addons/hr_goal/view/type.xml diff --git a/addons/hr_goal/__openerp__.py b/addons/hr_goal/__openerp__.py index 187fb15b121..9d3a299a926 100644 --- a/addons/hr_goal/__openerp__.py +++ b/addons/hr_goal/__openerp__.py @@ -19,20 +19,18 @@ # ############################################################################## { - 'name': 'Goal', + 'name': 'Gamification', 'version': '1.0', 'author': 'OpenERP SA', 'category': 'Human Resources', - 'depends': ['base', 'hr'], - 'description': """HR Goal definition - -Defined goals to users""", + 'depends': ['mail'], + 'description': """Gamification of goals""", 'data': [ - 'view/criteria.xml', - 'view/definition.xml', - 'view/instance.xml', - 'view/preset.xml', + 'view/type.xml', + # 'view/definition.xml', + # 'view/instance.xml', + # 'view/preset.xml', ], 'installable': True, 'application': True, diff --git a/addons/hr_goal/goal.py b/addons/hr_goal/goal.py index 0fd5da3a16a..5f2c420add9 100644 --- a/addons/hr_goal/goal.py +++ b/addons/hr_goal/goal.py @@ -23,102 +23,164 @@ from openerp.osv import fields, osv from datetime import date -class hr_goal_criteria(osv.Model): - """Goal criteria definition +GAMIFICATION_GOAL_STATUS = [ + ('inprogress','In progress'), + ('reached','Reached'), + ('failed','Failed'), +] - A criteria defining a way to set an objective and evaluate it - Each module wanting to be able to set goals to the users needs to create - a new goal_criteria - """ - _name = 'hr.goal.criteria' - _description = 'Goal criteria' +# I don't see why it would be different but just in case... +GAMIFICATION_PLAN_STATUS = GAMIFICATION_GOAL_STATUS - _columns = { - 'name': fields.char('Name'), +GAMIFICATION_PERIOD_STATUS = [ + ('once','No automatic assigment'), + ('daily','Daily'), + ('weekly','Weekly'), + ('monthly','Monthly'), + ('yearly', 'Yearly') +] + +class gamification_goal_type(osv.Model): + """Goal type definition + + A goal type defining a way to set an objective and evaluate it + Each module wanting to be able to set goals to the users needs to create + a new gamification_goal_type + """ + _name = 'gamification.goal.type' + _description = 'Gamification goal type' + + _columns = { + 'name': fields.char('Name', required=True), 'description': fields.char('Description'), - 'evaluated_field': fields.many2one('ir.model.fields', - string='Evaluated field'), + 'computation_mode': fields.selection( + ( + ('s','Sum'), + ('c','Count'), + ('m','Manually'), + ), + string="Mode of computation", + description="""How is computed the goal value : +- 'Sum' for the total of the values if the 'Evaluated field' +- 'Count' for the number of entries +- 'Manually' for user defined values""", + required=True), + 'object': fields.many2one('ir.model', + string='Object', + description='The object type for the field to evaluate' ), + 'field': fields.many2one('ir.model.fields', + string='Evaluated field', + description='The field containing the value to evaluate' ), + 'field_date': fields.many2one('ir.model.fields', + string='Evaluated date field', + description='The date to use for the time period evaluated'), + 'domain': fields.char("Domain"), # how to apply it ? + 'condition' : fields.selection( + ( + ('minus','<='), + ('plus','>=') + ), + string='Validation condition', + description='A goal is considered as completed when the current value is compared to the value to reach'), + 'sequence' : fields.integer('Sequence', + description='Sequence number for ordering', + required=True), + } + + _defaults = { + 'sequence': 0, + 'condition': 'plus', } -class hr_goal(osv.Model): - """Goal instance for a user - An individual goal for a user on a specified time period - """ +class gamification_goal(osv.Model): + """Goal instance for a user - _name = 'hr.goal.instance' - _description = 'Goal instance' + An individual goal for a user on a specified time period + """ - _columns = { - 'criteria_id' : fields.many2one('hr.goal.criteria', string='Criteria'), - 'user_id' : fields.many2one('res.users', string='User'), - 'start_date' : fields.date('Start date'), - 'end_date' : fields.date('End date'), - 'to_reach' : fields.float('To reach'), - 'current' : fields.float('Current'), - } + _name = 'gamification.goal' + _description = 'Gamification goal instance' + _inherit = 'mail.thread' - def _compute_default_end_date(self, cr, uid, ids, field_name, arg, - context=None): - hr_goal = self.browse(cr, uid, ids, context) - if hr_goal.start_date: - return hr_goal.start_date + datetime.timedelta(days=1) - else: - return fields.date.today() + datetime.timedelta(days=1) + _columns = { + 'type_id' : fields.many2one('gamification.goal.type', + string='Goal type', + required=True), + 'user_id' : fields.many2one('res.users', string='User', required=True), + 'plan_id' : fields.many2one('gamification.goal.plan', + string='Goal plan'), + 'start_date' : fields.date('Start date'), + 'end_date' : fields.date('End date'), # no start and end = always active + 'target_goal' : fields.float('To reach', + required=True, + track_visibility = 'always'), # no goal = global index + 'current' : fields.float('Current', + required=True, + track_visibility = 'always'), + 'status': fields.selection(GAMIFICATION_GOAL_STATUS, + string='Status', + required=True, + track_visibility = 'always'), + } - _defaults = { + _defaults = { 'start_date': fields.date.today, - 'end_date': _compute_default_end_date, - 'current': "", + 'current': 0, + 'status': 'inprogress', } +class gamification_goal_plan(osv.Model): + """Ga;ification goal plan -class hr_goal_definition(osv.Model): - """Goal definition + Set of predifined goals to be able to automate goal settings or + quickly apply several goals manually to a group of users - Predifined goal for 'hr_goal_preset' - """ + If 'user_ids' is defined and 'period' is different than 'one', the set will + be assigned to the users for each period (eg: every 1st of each month if + 'monthly' is selected) + """ - _name = 'hr.goal.definition' - _description = 'Goal definition' + _name = 'gamification.goal.plan' + _description = 'Gamification goal plan' - _columns = { - 'criteria_id' : fields.many2one('hr.goal.criteria', - string='Criteria'), - 'default_to_reach' : fields.float('Default value to reach'), - } + _columns = { + 'name' : fields.char('Plan name', required=True), + 'user_ids' : fields.many2many('res.users', + string='Definition', + description="list of users to which the goal will be set"), + 'group_id' : fields.many2one('res.groups', string='Group'), + 'period' : fields.selection(GAMIFICATION_PERIOD_STATUS, + string='Period', + description='Period of automatic goal assigment, will be done manually if none is selected', + required=True), + 'status': fields.selection(GAMIFICATION_PLAN_STATUS, + string='Status', + required=True), + } - -class hr_goal_preset(osv.Model): - """Goal preset - - Set of predifined goals to be able to automate goal settings or - quickly apply several goals manually - - If both 'group_id' and 'period' are defined, the set will be assigned to the - group for each period (eg: every 1st of each month if 'monthly' is selected) - """ - - _name = 'hr.goal.preset' - _description = 'Goal preset' - - _columns = { - 'name' : fields.char('Set name'), - 'definition_id' : fields.many2many('hr.goal.definition', - string='Definition'), - 'group_id' : fields.many2one('res.groups', string='Group'), - 'period' : fields.selection( - ( - ('n','No automatic assigment'), - ('d','Daily'), - ('m','Monthly'), - ('y', 'Yearly') - ), - string='Period', - description='Period of automatic goal assigment, ignored if no group is selected'), - } - - _defaults = { - 'period': 'n', + _defaults = { + 'period': 'once', + 'status': 'inprogress', + } + + +class gamification_goal_planline(osv.Model): + """Gamification goal planline + + Predifined goal for 'gamification_goal_plan' + These are generic list of goals with only the target goal defined + Should only be created for the gamification_goal_plan object + """ + + _name = 'gamification.goal.planline' + _description = 'Gamification generic goal for plan' + + _columns = { + 'plan_id' : fields.many2one('gamification.goal.plan', + string='Plan'), + 'type_id' : fields.many2one('gamification.goal.type', + string='Goal type'), + 'target_goal' : fields.float('Target value to reach'), } diff --git a/addons/hr_goal/view/criteria.xml b/addons/hr_goal/view/criteria.xml deleted file mode 100644 index 8e47f656c10..00000000000 --- a/addons/hr_goal/view/criteria.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - Criterias - hr.goal.criteria - tree,form - - - - - - - - - \ No newline at end of file diff --git a/addons/hr_goal/view/type.xml b/addons/hr_goal/view/type.xml new file mode 100644 index 00000000000..5f33de1761e --- /dev/null +++ b/addons/hr_goal/view/type.xml @@ -0,0 +1,16 @@ + + + + + + Gamification + gamification.goal.type + tree,form + + + + + + + + \ No newline at end of file From bad8fff69c61d1b6e5759865de6b9a500b8cffba Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 15 Feb 2013 10:16:38 +0100 Subject: [PATCH 004/521] [REF] better definition of gamification models bzr revid: mat@openerp.com-20130215091638-f1ipm1p9cp2s88p9 --- addons/hr_goal/goal.py | 49 +++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/addons/hr_goal/goal.py b/addons/hr_goal/goal.py index 5f2c420add9..59cdc7c5f72 100644 --- a/addons/hr_goal/goal.py +++ b/addons/hr_goal/goal.py @@ -40,6 +40,18 @@ GAMIFICATION_PERIOD_STATUS = [ ('yearly', 'Yearly') ] +GAMIFICATION_COMPUTATION_MODE = [ + ('sum','Sum'), + ('count','Count'), + ('manually','Manually') +] + +GAMIFICATION_VALIDATION_CONDITION = [ + ('minus','<='), + ('plus','>=') +] + + class gamification_goal_type(osv.Model): """Goal type definition @@ -52,44 +64,37 @@ class gamification_goal_type(osv.Model): _columns = { 'name': fields.char('Name', required=True), - 'description': fields.char('Description'), - 'computation_mode': fields.selection( - ( - ('s','Sum'), - ('c','Count'), - ('m','Manually'), - ), + 'description': fields.text('Description'), + 'computation_mode': fields.selection(GAMIFICATION_COMPUTATION_MODE, string="Mode of computation", - description="""How is computed the goal value : -- 'Sum' for the total of the values if the 'Evaluated field' -- 'Count' for the number of entries + help="""How is computed the goal value :\n +- 'Sum' for the total of the values if the 'Evaluated field'\n +- 'Count' for the number of entries\n - 'Manually' for user defined values""", required=True), 'object': fields.many2one('ir.model', string='Object', - description='The object type for the field to evaluate' ), + help='The object type for the field to evaluate' ), 'field': fields.many2one('ir.model.fields', string='Evaluated field', - description='The field containing the value to evaluate' ), + help='The field containing the value to evaluate' ), 'field_date': fields.many2one('ir.model.fields', string='Evaluated date field', - description='The date to use for the time period evaluated'), + help='The date to use for the time period evaluated'), 'domain': fields.char("Domain"), # how to apply it ? - 'condition' : fields.selection( - ( - ('minus','<='), - ('plus','>=') - ), + 'condition' : fields.selection(GAMIFICATION_VALIDATION_CONDITION, string='Validation condition', - description='A goal is considered as completed when the current value is compared to the value to reach'), + help='A goal is considered as completed when the current value is compared to the value to reach', + required=True), 'sequence' : fields.integer('Sequence', - description='Sequence number for ordering', + help='Sequence number for ordering', required=True), } _defaults = { 'sequence': 0, 'condition': 'plus', + 'computation_mode':'manually', } @@ -149,11 +154,11 @@ class gamification_goal_plan(osv.Model): 'name' : fields.char('Plan name', required=True), 'user_ids' : fields.many2many('res.users', string='Definition', - description="list of users to which the goal will be set"), + help="list of users to which the goal will be set"), 'group_id' : fields.many2one('res.groups', string='Group'), 'period' : fields.selection(GAMIFICATION_PERIOD_STATUS, string='Period', - description='Period of automatic goal assigment, will be done manually if none is selected', + help='Period of automatic goal assigment, will be done manually if none is selected', required=True), 'status': fields.selection(GAMIFICATION_PLAN_STATUS, string='Status', From 77a3ff7ca7d63874dcad3106b83ce620031e0a8c Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 15 Feb 2013 10:24:07 +0100 Subject: [PATCH 005/521] [IMP] views for gamification goal types in Settings menu bzr revid: mat@openerp.com-20130215092407-gyu3112u4kkpf980 --- addons/hr_goal/__openerp__.py | 1 + addons/hr_goal/view/type.xml | 46 ++++++++++++++++++++++++++++++++--- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/addons/hr_goal/__openerp__.py b/addons/hr_goal/__openerp__.py index 9d3a299a926..08854e9cf23 100644 --- a/addons/hr_goal/__openerp__.py +++ b/addons/hr_goal/__openerp__.py @@ -27,6 +27,7 @@ 'description': """Gamification of goals""", 'data': [ + 'view/menu.xml', 'view/type.xml', # 'view/definition.xml', # 'view/instance.xml', diff --git a/addons/hr_goal/view/type.xml b/addons/hr_goal/view/type.xml index 5f33de1761e..bfcf7c93b62 100644 --- a/addons/hr_goal/view/type.xml +++ b/addons/hr_goal/view/type.xml @@ -3,14 +3,52 @@ - Gamification + Goal types gamification.goal.type tree,form - - - + + Goal types list + gamification.goal.type + + + + + + + + + + + + + Goal types form + gamification.goal.type + +
+ +

+ +

+ + + + + + + + + + + + + + +
+
+
+
\ No newline at end of file From e14c3a95d8424ccc01754ec3e9d84fa6180e52be Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 15 Feb 2013 11:42:14 +0100 Subject: [PATCH 006/521] [ADD] gamification:view for the goal object bzr revid: mat@openerp.com-20130215104214-ebpw2uglqg7h4byc --- addons/hr_goal/__openerp__.py | 8 ++-- addons/hr_goal/goal.py | 1 - addons/hr_goal/view/goal.xml | 67 ++++++++++++++++++++++++++++++++ addons/hr_goal/view/instance.xml | 13 ------- addons/hr_goal/view/type.xml | 2 +- 5 files changed, 71 insertions(+), 20 deletions(-) create mode 100644 addons/hr_goal/view/goal.xml delete mode 100644 addons/hr_goal/view/instance.xml diff --git a/addons/hr_goal/__openerp__.py b/addons/hr_goal/__openerp__.py index 08854e9cf23..cc2a70dffbb 100644 --- a/addons/hr_goal/__openerp__.py +++ b/addons/hr_goal/__openerp__.py @@ -27,12 +27,10 @@ 'description': """Gamification of goals""", 'data': [ - 'view/menu.xml', 'view/type.xml', - # 'view/definition.xml', - # 'view/instance.xml', - # 'view/preset.xml', - ], + 'view/goal.xml', + 'view/menu.xml', + ], 'installable': True, 'application': True, } diff --git a/addons/hr_goal/goal.py b/addons/hr_goal/goal.py index 59cdc7c5f72..88c26a1767c 100644 --- a/addons/hr_goal/goal.py +++ b/addons/hr_goal/goal.py @@ -130,7 +130,6 @@ class gamification_goal(osv.Model): } _defaults = { - 'start_date': fields.date.today, 'current': 0, 'status': 'inprogress', } diff --git a/addons/hr_goal/view/goal.xml b/addons/hr_goal/view/goal.xml new file mode 100644 index 00000000000..3b60aac1976 --- /dev/null +++ b/addons/hr_goal/view/goal.xml @@ -0,0 +1,67 @@ + + + + + Goals + gamification.goal + tree,form,calendar + + + + Goal list + gamification.goal + + + + + + + + + + + + + + + Goal form + gamification.goal + +
+ + + + + + + + + + + + + + + + + + +
+
+
+ + + Goal calendar + gamification.goal + + + + + + + +
+
\ No newline at end of file diff --git a/addons/hr_goal/view/instance.xml b/addons/hr_goal/view/instance.xml deleted file mode 100644 index d89f2f1ca22..00000000000 --- a/addons/hr_goal/view/instance.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - Goals - hr.goal.instance - tree,form - - - - - \ No newline at end of file diff --git a/addons/hr_goal/view/type.xml b/addons/hr_goal/view/type.xml index bfcf7c93b62..c189685e4e2 100644 --- a/addons/hr_goal/view/type.xml +++ b/addons/hr_goal/view/type.xml @@ -2,7 +2,7 @@ - + Goal types gamification.goal.type tree,form From 357c08da1704fd83f6638088b55710161cc2a6bf Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 15 Feb 2013 11:44:17 +0100 Subject: [PATCH 007/521] [FIX] add gamification menu view bzr revid: mat@openerp.com-20130215104417-zisq806feo4l45hy --- addons/hr_goal/view/menu.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 addons/hr_goal/view/menu.xml diff --git a/addons/hr_goal/view/menu.xml b/addons/hr_goal/view/menu.xml new file mode 100644 index 00000000000..e699f445591 --- /dev/null +++ b/addons/hr_goal/view/menu.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file From 5dfd8de04dd3cf3de4e4ffc84fb0407036c9c232 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 15 Feb 2013 12:03:58 +0100 Subject: [PATCH 008/521] [REF] changing gamification goal plan status possibilities bzr revid: mat@openerp.com-20130215110358-o52snkry52mtdm3z --- addons/hr_goal/goal.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/hr_goal/goal.py b/addons/hr_goal/goal.py index 88c26a1767c..ae2c773fff9 100644 --- a/addons/hr_goal/goal.py +++ b/addons/hr_goal/goal.py @@ -29,8 +29,11 @@ GAMIFICATION_GOAL_STATUS = [ ('failed','Failed'), ] -# I don't see why it would be different but just in case... -GAMIFICATION_PLAN_STATUS = GAMIFICATION_GOAL_STATUS +GAMIFICATION_PLAN_STATUS = [ + ('draft','Draft'), + ('inprogress','In progress'), + ('done','Done'), +] GAMIFICATION_PERIOD_STATUS = [ ('once','No automatic assigment'), From ca712230e2b0cf2927971ce3a8715e9ae8a015e7 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 15 Feb 2013 14:09:21 +0100 Subject: [PATCH 009/521] [ADD] plan views for gamification moduel bzr revid: mat@openerp.com-20130215130921-ca64o47syxn6vob1 --- addons/hr_goal/__openerp__.py | 1 + addons/hr_goal/goal.py | 6 ++- addons/hr_goal/view/definition.xml | 15 ------ addons/hr_goal/view/menu.xml | 12 ++--- addons/hr_goal/view/plan.xml | 73 ++++++++++++++++++++++++++++++ addons/hr_goal/view/preset.xml | 13 ------ 6 files changed, 85 insertions(+), 35 deletions(-) delete mode 100644 addons/hr_goal/view/definition.xml create mode 100644 addons/hr_goal/view/plan.xml delete mode 100644 addons/hr_goal/view/preset.xml diff --git a/addons/hr_goal/__openerp__.py b/addons/hr_goal/__openerp__.py index cc2a70dffbb..896a5b4eb01 100644 --- a/addons/hr_goal/__openerp__.py +++ b/addons/hr_goal/__openerp__.py @@ -29,6 +29,7 @@ 'data': [ 'view/type.xml', 'view/goal.xml', + 'view/plan.xml', 'view/menu.xml', ], 'installable': True, diff --git a/addons/hr_goal/goal.py b/addons/hr_goal/goal.py index ae2c773fff9..03a1f741440 100644 --- a/addons/hr_goal/goal.py +++ b/addons/hr_goal/goal.py @@ -155,8 +155,12 @@ class gamification_goal_plan(osv.Model): _columns = { 'name' : fields.char('Plan name', required=True), 'user_ids' : fields.many2many('res.users', - string='Definition', + string='Users', help="list of users to which the goal will be set"), + 'planline_ids' : fields.one2many('gamification.goal.planline', + 'plan_id', + string='Planline', + help="list of goals that will be set"), 'group_id' : fields.many2one('res.groups', string='Group'), 'period' : fields.selection(GAMIFICATION_PERIOD_STATUS, string='Period', diff --git a/addons/hr_goal/view/definition.xml b/addons/hr_goal/view/definition.xml deleted file mode 100644 index 47241f6710b..00000000000 --- a/addons/hr_goal/view/definition.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - Goal definitions - hr.goal.definition - tree,form - - - - - - - \ No newline at end of file diff --git a/addons/hr_goal/view/menu.xml b/addons/hr_goal/view/menu.xml index e699f445591..f26feb1ffef 100644 --- a/addons/hr_goal/view/menu.xml +++ b/addons/hr_goal/view/menu.xml @@ -1,13 +1,13 @@ - - - - - - + + + + + + \ No newline at end of file diff --git a/addons/hr_goal/view/plan.xml b/addons/hr_goal/view/plan.xml new file mode 100644 index 00000000000..3d9760bd37d --- /dev/null +++ b/addons/hr_goal/view/plan.xml @@ -0,0 +1,73 @@ + + + + + + Goal plans + gamification.goal.plan + tree,form + + + + Goal plans list + gamification.goal.plan + + + + + + + + + + + Goal plan form + gamification.goal.plan + +
+ +

+ +

+ + + + + + + + + + + + + + + + + + + + +
+ X +
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
\ No newline at end of file diff --git a/addons/hr_goal/view/preset.xml b/addons/hr_goal/view/preset.xml deleted file mode 100644 index 270149b812e..00000000000 --- a/addons/hr_goal/view/preset.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - Presets - hr.goal.preset - tree,form - - - - - \ No newline at end of file From 92c03ea75cd87381b09d01ac0dd7bafa922dfe9a Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 15 Feb 2013 14:32:34 +0100 Subject: [PATCH 010/521] [ADD] report for goal plans bzr revid: mat@openerp.com-20130215133234-kp49lzfd5tjj1o7c --- addons/hr_goal/goal.py | 30 +++++++++++++++++++++++++++++- addons/hr_goal/view/plan.xml | 10 ++++++++-- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/addons/hr_goal/goal.py b/addons/hr_goal/goal.py index 03a1f741440..259b483583b 100644 --- a/addons/hr_goal/goal.py +++ b/addons/hr_goal/goal.py @@ -54,6 +54,19 @@ GAMIFICATION_VALIDATION_CONDITION = [ ('plus','>=') ] +GAMIFICATION_REPORT_MODE = [ + ('board','Leader board'), + ('progressbar','Personal progressbar') +] + +GAMIFICATION_REPORT_FREQ = [ + ('onchange','On change'), + ('daily','Daily'), + ('weekly','Weekly'), + ('monthly','Monthly'), + ('yearly', 'Yearly') +] + class gamification_goal_type(osv.Model): """Goal type definition @@ -161,7 +174,9 @@ class gamification_goal_plan(osv.Model): 'plan_id', string='Planline', help="list of goals that will be set"), - 'group_id' : fields.many2one('res.groups', string='Group'), + 'autojoin_group_id' : fields.many2one('res.groups', + string='Group', + help='Group of users whose members will automatically be added to the users'), 'period' : fields.selection(GAMIFICATION_PERIOD_STATUS, string='Period', help='Period of automatic goal assigment, will be done manually if none is selected', @@ -169,11 +184,24 @@ class gamification_goal_plan(osv.Model): 'status': fields.selection(GAMIFICATION_PLAN_STATUS, string='Status', required=True), + 'report_mode':fields.selection(GAMIFICATION_REPORT_MODE, + string="Mode", + help='How is displayed the results, shared or in a signle progressbar', + required=True), + 'report_message_frequency':fields.selection(GAMIFICATION_REPORT_FREQ, + string="Frequency", + required=True), + 'report_message_group_id' : fields.many2one('mail.group', + string='Group', + help='Group that will receive the report in addition to the user'), + 'report_header' : fields.text('Report header'), } _defaults = { 'period': 'once', 'status': 'inprogress', + 'report_mode' : 'progressbar', + 'report_message_frequency' : 'onchange', } diff --git a/addons/hr_goal/view/plan.xml b/addons/hr_goal/view/plan.xml index 3d9760bd37d..8d177c5201b 100644 --- a/addons/hr_goal/view/plan.xml +++ b/addons/hr_goal/view/plan.xml @@ -30,10 +30,16 @@ - + + + + + + + @@ -41,7 +47,7 @@ - + From 2004f2bcd7dcaebfcac66ded0f24530a00b1b67e Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 15 Feb 2013 14:59:40 +0100 Subject: [PATCH 011/521] [IMP] editable planline for gaming module bzr revid: mat@openerp.com-20130215135940-mji5ype1wsteduob --- addons/hr_goal/view/plan.xml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/addons/hr_goal/view/plan.xml b/addons/hr_goal/view/plan.xml index 8d177c5201b..d8e392020f1 100644 --- a/addons/hr_goal/view/plan.xml +++ b/addons/hr_goal/view/plan.xml @@ -43,7 +43,12 @@ - + + + + + + @@ -75,5 +80,18 @@
+ + + + Goal planline list + gamification.goal.planline + + + + + + + +
\ No newline at end of file From 8768bd81501adbda8bbe697eb74007333a78fa5e Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 15 Feb 2013 15:16:51 +0100 Subject: [PATCH 012/521] [IMP] gamification: use state instead of status bzr revid: mat@openerp.com-20130215141651-5ktcyekk9subj6ji --- addons/hr_goal/goal.py | 20 ++++++++++---------- addons/hr_goal/view/goal.xml | 12 +++++++++--- addons/hr_goal/view/plan.xml | 6 +++--- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/addons/hr_goal/goal.py b/addons/hr_goal/goal.py index 259b483583b..1808f0a9ec8 100644 --- a/addons/hr_goal/goal.py +++ b/addons/hr_goal/goal.py @@ -23,19 +23,19 @@ from openerp.osv import fields, osv from datetime import date -GAMIFICATION_GOAL_STATUS = [ +GAMIFICATION_GOAL_STATE = [ ('inprogress','In progress'), ('reached','Reached'), ('failed','Failed'), ] -GAMIFICATION_PLAN_STATUS = [ +GAMIFICATION_PLAN_STATE = [ ('draft','Draft'), ('inprogress','In progress'), ('done','Done'), ] -GAMIFICATION_PERIOD_STATUS = [ +GAMIFICATION_PERIOD_STATE = [ ('once','No automatic assigment'), ('daily','Daily'), ('weekly','Weekly'), @@ -139,15 +139,15 @@ class gamification_goal(osv.Model): 'current' : fields.float('Current', required=True, track_visibility = 'always'), - 'status': fields.selection(GAMIFICATION_GOAL_STATUS, - string='Status', + 'state': fields.selection(GAMIFICATION_GOAL_STATE, + string='State', required=True, track_visibility = 'always'), } _defaults = { 'current': 0, - 'status': 'inprogress', + 'state': 'inprogress', } @@ -177,12 +177,12 @@ class gamification_goal_plan(osv.Model): 'autojoin_group_id' : fields.many2one('res.groups', string='Group', help='Group of users whose members will automatically be added to the users'), - 'period' : fields.selection(GAMIFICATION_PERIOD_STATUS, + 'period' : fields.selection(GAMIFICATION_PERIOD_STATE, string='Period', help='Period of automatic goal assigment, will be done manually if none is selected', required=True), - 'status': fields.selection(GAMIFICATION_PLAN_STATUS, - string='Status', + 'state': fields.selection(GAMIFICATION_PLAN_STATE, + string='State', required=True), 'report_mode':fields.selection(GAMIFICATION_REPORT_MODE, string="Mode", @@ -199,7 +199,7 @@ class gamification_goal_plan(osv.Model): _defaults = { 'period': 'once', - 'status': 'inprogress', + 'state': 'inprogress', 'report_mode' : 'progressbar', 'report_message_frequency' : 'onchange', } diff --git a/addons/hr_goal/view/goal.xml b/addons/hr_goal/view/goal.xml index 3b60aac1976..84ecbc7b0a5 100644 --- a/addons/hr_goal/view/goal.xml +++ b/addons/hr_goal/view/goal.xml @@ -11,14 +11,14 @@ Goal list gamification.goal - + - + @@ -28,6 +28,12 @@ gamification.goal
+
+
@@ -42,7 +48,7 @@ - + diff --git a/addons/hr_goal/view/plan.xml b/addons/hr_goal/view/plan.xml index d8e392020f1..a4ab2148f1b 100644 --- a/addons/hr_goal/view/plan.xml +++ b/addons/hr_goal/view/plan.xml @@ -12,10 +12,10 @@ Goal plans list gamification.goal.plan - + - + @@ -32,7 +32,7 @@ - + From beefb1ef740977536e98cdb66df1ee60ffdc9db6 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 15 Feb 2013 15:29:41 +0100 Subject: [PATCH 013/521] [IMP] gamification: workflow buttons bzr revid: mat@openerp.com-20130215142941-laoi71wkjlychxy1 --- addons/hr_goal/view/plan.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/addons/hr_goal/view/plan.xml b/addons/hr_goal/view/plan.xml index a4ab2148f1b..6a23f5c42bc 100644 --- a/addons/hr_goal/view/plan.xml +++ b/addons/hr_goal/view/plan.xml @@ -25,6 +25,12 @@ gamification.goal.plan +
+

From 44fa903585bc95a881bb50eab8a1e0fb3c3cc7ba Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 15 Feb 2013 15:37:35 +0100 Subject: [PATCH 014/521] [IMP] gamification: no state field in forms bzr revid: mat@openerp.com-20130215143735-l92r0s1bc51nopx8 --- addons/hr_goal/view/goal.xml | 1 - addons/hr_goal/view/plan.xml | 1 - 2 files changed, 2 deletions(-) diff --git a/addons/hr_goal/view/goal.xml b/addons/hr_goal/view/goal.xml index 84ecbc7b0a5..ab4ee3f8b3d 100644 --- a/addons/hr_goal/view/goal.xml +++ b/addons/hr_goal/view/goal.xml @@ -48,7 +48,6 @@ - diff --git a/addons/hr_goal/view/plan.xml b/addons/hr_goal/view/plan.xml index 6a23f5c42bc..8618f64c37a 100644 --- a/addons/hr_goal/view/plan.xml +++ b/addons/hr_goal/view/plan.xml @@ -38,7 +38,6 @@ - From aeb3ea30b3652ce7abba287347875e45e7cfe255 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 15 Feb 2013 15:53:48 +0100 Subject: [PATCH 015/521] [FIX] gamification: fix form id for plan bzr revid: mat@openerp.com-20130215145348-kfrh6eaj3z2k65bh --- addons/hr_goal/view/plan.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/hr_goal/view/plan.xml b/addons/hr_goal/view/plan.xml index 8618f64c37a..dca2c545354 100644 --- a/addons/hr_goal/view/plan.xml +++ b/addons/hr_goal/view/plan.xml @@ -20,7 +20,7 @@ - + Goal plan form gamification.goal.plan From 2e0186dab07363220f75f91fa8b5236d142587a7 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 15 Feb 2013 15:54:15 +0100 Subject: [PATCH 016/521] [ADD] gamification: add completeness progressbar bzr revid: mat@openerp.com-20130215145415-39cx5v3pf8mn5ye7 --- addons/hr_goal/goal.py | 14 ++++++++++++++ addons/hr_goal/view/goal.xml | 1 + 2 files changed, 15 insertions(+) diff --git a/addons/hr_goal/goal.py b/addons/hr_goal/goal.py index 1808f0a9ec8..cc4c525deae 100644 --- a/addons/hr_goal/goal.py +++ b/addons/hr_goal/goal.py @@ -107,6 +107,7 @@ class gamification_goal_type(osv.Model): required=True), } + _order = 'sequence' _defaults = { 'sequence': 0, 'condition': 'plus', @@ -124,6 +125,16 @@ class gamification_goal(osv.Model): _description = 'Gamification goal instance' _inherit = 'mail.thread' + def _get_completeness(self, cr, uid, ids, field_name, arg, context=None): + res = {} + for goal in self.browse(cr, uid, ids, context): + # more 100% ? + if goal.target_goal > 0: + res[goal.id] = 100.0 * goal.current / goal.target_goal + else: + res[goal.id] = 0.0 + return res + _columns = { 'type_id' : fields.many2one('gamification.goal.type', string='Goal type', @@ -139,6 +150,9 @@ class gamification_goal(osv.Model): 'current' : fields.float('Current', required=True, track_visibility = 'always'), + 'completeness': fields.function(_get_completeness, + type='float', + string='Occupation'), 'state': fields.selection(GAMIFICATION_GOAL_STATE, string='State', required=True, diff --git a/addons/hr_goal/view/goal.xml b/addons/hr_goal/view/goal.xml index ab4ee3f8b3d..c711927044c 100644 --- a/addons/hr_goal/view/goal.xml +++ b/addons/hr_goal/view/goal.xml @@ -18,6 +18,7 @@ + From 73b558e3c37a5d74815937feb8309bf0ef334b8c Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 15 Feb 2013 16:05:20 +0100 Subject: [PATCH 017/521] [REF] gamification: change name of folder bzr revid: mat@openerp.com-20130215150520-50fnb7rx690t8yq9 --- addons/{hr_goal => gamification}/__init__.py | 0 addons/{hr_goal => gamification}/__openerp__.py | 0 addons/{hr_goal => gamification}/goal.py | 0 addons/{hr_goal => gamification}/view/goal.xml | 0 addons/{hr_goal => gamification}/view/menu.xml | 0 addons/{hr_goal => gamification}/view/plan.xml | 0 addons/{hr_goal => gamification}/view/type.xml | 0 7 files changed, 0 insertions(+), 0 deletions(-) rename addons/{hr_goal => gamification}/__init__.py (100%) rename addons/{hr_goal => gamification}/__openerp__.py (100%) rename addons/{hr_goal => gamification}/goal.py (100%) rename addons/{hr_goal => gamification}/view/goal.xml (100%) rename addons/{hr_goal => gamification}/view/menu.xml (100%) rename addons/{hr_goal => gamification}/view/plan.xml (100%) rename addons/{hr_goal => gamification}/view/type.xml (100%) diff --git a/addons/hr_goal/__init__.py b/addons/gamification/__init__.py similarity index 100% rename from addons/hr_goal/__init__.py rename to addons/gamification/__init__.py diff --git a/addons/hr_goal/__openerp__.py b/addons/gamification/__openerp__.py similarity index 100% rename from addons/hr_goal/__openerp__.py rename to addons/gamification/__openerp__.py diff --git a/addons/hr_goal/goal.py b/addons/gamification/goal.py similarity index 100% rename from addons/hr_goal/goal.py rename to addons/gamification/goal.py diff --git a/addons/hr_goal/view/goal.xml b/addons/gamification/view/goal.xml similarity index 100% rename from addons/hr_goal/view/goal.xml rename to addons/gamification/view/goal.xml diff --git a/addons/hr_goal/view/menu.xml b/addons/gamification/view/menu.xml similarity index 100% rename from addons/hr_goal/view/menu.xml rename to addons/gamification/view/menu.xml diff --git a/addons/hr_goal/view/plan.xml b/addons/gamification/view/plan.xml similarity index 100% rename from addons/hr_goal/view/plan.xml rename to addons/gamification/view/plan.xml diff --git a/addons/hr_goal/view/type.xml b/addons/gamification/view/type.xml similarity index 100% rename from addons/hr_goal/view/type.xml rename to addons/gamification/view/type.xml From 33be2c1b8aff3f5d631b824686a802ba423f48f3 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 15 Feb 2013 17:02:04 +0100 Subject: [PATCH 018/521] [IMP] gamification: change of state when using buttons bzr revid: mat@openerp.com-20130215160204-0jt6yw01lytjgyto --- addons/gamification/goal.py | 24 ++++++++++++++++++++++-- addons/gamification/view/goal.xml | 6 +++--- addons/gamification/view/plan.xml | 6 +++--- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/addons/gamification/goal.py b/addons/gamification/goal.py index cc4c525deae..e77eb5ff922 100644 --- a/addons/gamification/goal.py +++ b/addons/gamification/goal.py @@ -164,6 +164,16 @@ class gamification_goal(osv.Model): 'state': 'inprogress', } + def action_reach(self, cr, uid, ids, context=None): + return self.write(cr, uid, ids, {'state': 'reached'}, context=context) + + def action_fail(self, cr, uid, ids, context=None): + return self.write(cr, uid, ids, {'state': 'failed'}, context=context) + + def action_cancel(self, cr, uid, ids, context=None): + return self.write(cr, uid, ids, {'state': 'inprogress'}, context=context) + + class gamification_goal_plan(osv.Model): """Ga;ification goal plan @@ -206,18 +216,28 @@ class gamification_goal_plan(osv.Model): string="Frequency", required=True), 'report_message_group_id' : fields.many2one('mail.group', - string='Group', + string='Report to', help='Group that will receive the report in addition to the user'), 'report_header' : fields.text('Report header'), } _defaults = { 'period': 'once', - 'state': 'inprogress', + 'state': 'draft', 'report_mode' : 'progressbar', 'report_message_frequency' : 'onchange', } + def action_start(self, cr, uid, ids, context=None): + return self.write(cr, uid, ids, {'state': 'inprogress'}, context=context) + + def action_close(self, cr, uid, ids, context=None): + return self.write(cr, uid, ids, {'state': 'done'}, context=context) + + def action_cancel(self, cr, uid, ids, context=None): + return self.write(cr, uid, ids, {'state': 'draft'}, context=context) + + class gamification_goal_planline(osv.Model): """Gamification goal planline diff --git a/addons/gamification/view/goal.xml b/addons/gamification/view/goal.xml index c711927044c..80a44e92c2d 100644 --- a/addons/gamification/view/goal.xml +++ b/addons/gamification/view/goal.xml @@ -30,9 +30,9 @@
-
diff --git a/addons/gamification/view/plan.xml b/addons/gamification/view/plan.xml index dca2c545354..f29ca2f7c62 100644 --- a/addons/gamification/view/plan.xml +++ b/addons/gamification/view/plan.xml @@ -26,9 +26,9 @@
-
From 974d4b6af08e12e28323829b2231677eb7840c72 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 15 Feb 2013 17:07:18 +0100 Subject: [PATCH 019/521] [IMP] gamification: hide done-fail state for goals bzr revid: mat@openerp.com-20130215160718-4n10mbzaxdaabp6e --- addons/gamification/view/goal.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/gamification/view/goal.xml b/addons/gamification/view/goal.xml index 80a44e92c2d..560e7d51c3f 100644 --- a/addons/gamification/view/goal.xml +++ b/addons/gamification/view/goal.xml @@ -33,7 +33,7 @@

+ + +
+
+ @@ -111,7 +125,8 @@ - + + diff --git a/addons/gamification/view/type.xml b/addons/gamification/view/type.xml index 8c3ec05f7f1..0740e5735cc 100644 --- a/addons/gamification/view/type.xml +++ b/addons/gamification/view/type.xml @@ -58,7 +58,10 @@ gamification.goal.type - + + + + From 0e23b01ffe921486273dc018e54ca22d170f9853 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Tue, 19 Feb 2013 15:37:22 +0100 Subject: [PATCH 033/521] [IMP] gamification: ondelete rules and better constraint bzr revid: mat@openerp.com-20130219143722-om96otvoemmfryyh --- addons/gamification/goal.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/addons/gamification/goal.py b/addons/gamification/goal.py index 0986ceaa731..e823e529e62 100644 --- a/addons/gamification/goal.py +++ b/addons/gamification/goal.py @@ -142,10 +142,12 @@ class gamification_goal(osv.Model): _columns = { 'type_id' : fields.many2one('gamification.goal.type', string='Goal Type', - required=True), + required=True, + ondelete="cascade"), 'user_id' : fields.many2one('res.users', string='User', required=True), 'plan_id' : fields.many2one('gamification.goal.plan', - string='Goal Plan'), + string='Goal Plan', + ondelete="cascade"), 'start_date' : fields.date('Start Date'), 'end_date' : fields.date('End Date'), # no start and end = always active 'target_goal' : fields.float('To Reach', @@ -244,13 +246,13 @@ class gamification_goal_plan(osv.Model): def _check_nonzero_users(self, cr, uid, ids, context=None): "checks that there is at least one user set" for plan in self.browse(cr, uid, ids, context): - if len(plan.user_ids) < 1: + if len(plan.user_ids) < 1 and plan.state != 'draft': return False return True _constraints = [ (_check_nonzero_planline, "At least one planline is required to create a goal plan", ['planline_ids']), - (_check_nonzero_users, "At least one user is required to create a goal plan", ['user_ids']), + (_check_nonzero_users, "At least one user is required to create a non-draft goal plan", ['user_ids']), ] def action_start(self, cr, uid, ids, context=None): @@ -309,10 +311,12 @@ class gamification_goal_planline(osv.Model): _columns = { 'plan_id' : fields.many2one('gamification.goal.plan', - string='Plan'), + string='Plan', + ondelete="cascade"), 'type_id' : fields.many2one('gamification.goal.type', string='Goal Type', - required=True), + required=True, + ondelete="cascade"), 'target_goal' : fields.float('Target Value to Reach', required=True), 'sequence_type' : fields.related('type_id','sequence', From d3750e5a8a43ad8b3eb49702fe74801f881776b7 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Tue, 19 Feb 2013 17:30:48 +0100 Subject: [PATCH 034/521] [IMP] gamification: default help messages and better default filter bzr revid: mat@openerp.com-20130219163048-d6cb69034nzbmj86 --- addons/gamification/goal.py | 22 ++++++++++------------ addons/gamification/view/goal.xml | 9 +++++++++ addons/gamification/view/plan.xml | 17 ++++++++++++++--- addons/gamification/view/type.xml | 9 +++++++++ 4 files changed, 42 insertions(+), 15 deletions(-) diff --git a/addons/gamification/goal.py b/addons/gamification/goal.py index e823e529e62..8fb9c4d7091 100644 --- a/addons/gamification/goal.py +++ b/addons/gamification/goal.py @@ -21,25 +21,23 @@ from openerp.osv import fields, osv -from datetime import date - GAMIFICATION_GOAL_STATE = [ - ('inprogress','In progress'), - ('reached','Reached'), - ('failed','Failed'), + ('inprogress', 'In progress'), + ('reached', 'Reached'), + ('failed', 'Failed'), ] GAMIFICATION_PLAN_STATE = [ - ('draft','Draft'), - ('inprogress','In progress'), - ('done','Done'), + ('draft', 'Draft'), + ('inprogress', 'In progress'), + ('done', 'Done'), ] GAMIFICATION_PERIOD_STATE = [ - ('once','Manual'), - ('daily','Daily'), - ('weekly','Weekly'), - ('monthly','Monthly'), + ('once', 'Manual'), + ('daily', 'Daily'), + ('weekly', 'Weekly'), + ('monthly', 'Monthly'), ('yearly', 'Yearly') ] diff --git a/addons/gamification/view/goal.xml b/addons/gamification/view/goal.xml index e582ff853f0..a788fdecd87 100644 --- a/addons/gamification/view/goal.xml +++ b/addons/gamification/view/goal.xml @@ -6,6 +6,15 @@ gamification.goal tree,form,calendar {'search_default_my_in_progress': 1} + +

+ Click to create a goal. +

+

+ A goal is defined by a user and a goal type. + Goals can be created automatically by using goal plans. +

+
diff --git a/addons/gamification/view/plan.xml b/addons/gamification/view/plan.xml index dc79a6b44fc..109b8ef3319 100644 --- a/addons/gamification/view/plan.xml +++ b/addons/gamification/view/plan.xml @@ -6,7 +6,18 @@ Goal Plans gamification.goal.plan tree,form - {'search_default_in_progress': 1} + {'search_default_draft_active': 1} + +

+ Click to create a goal plan. +

+

+ Goal plans allow to create and assign to users easily a list of goals. + A goal plan is a predifined list of goals types with a target value. + The plan can use a period (weekly, monthly...) for automatic creation of goals. + The goals are created for the specified users or memeber of the group. +

+
@@ -123,8 +134,8 @@ gamification.goal.plan - + diff --git a/addons/gamification/view/type.xml b/addons/gamification/view/type.xml index 0740e5735cc..9a6f1029ef2 100644 --- a/addons/gamification/view/type.xml +++ b/addons/gamification/view/type.xml @@ -6,6 +6,15 @@ Goal Types gamification.goal.type tree,form + +

+ Click to create a goal type. +

+

+ A goal type is a technical model of goal defining a condition to reach. + The dates, values to reach or users are defined in goal instance. +

+
From 6313de4dc8f86a19f92ea737e7d2df9f91066fb2 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Tue, 19 Feb 2013 17:52:15 +0100 Subject: [PATCH 035/521] [ADD] gamification: add remind and last update value bzr revid: mat@openerp.com-20130219165215-kscj3kpld3h8rz41 --- addons/gamification/goal.py | 4 ++++ addons/gamification/view/plan.xml | 1 + 2 files changed, 5 insertions(+) diff --git a/addons/gamification/goal.py b/addons/gamification/goal.py index 8fb9c4d7091..bc0057a6613 100644 --- a/addons/gamification/goal.py +++ b/addons/gamification/goal.py @@ -161,6 +161,8 @@ class gamification_goal(osv.Model): string='State', required=True, track_visibility = 'always'), + 'last_update' : fields.date('Last Update', + help="In case of manual goal, reminders are sent if the goal as not been updated for a while (defined in goal plan). Ignored in case of non-manual goal or goal not linked to a plan."), # } _defaults = { @@ -225,6 +227,8 @@ class gamification_goal_plan(osv.Model): string='Report to', help='Group that will receive the report in addition to the user'), 'report_header' : fields.text('Report Header'), + 'remind_update_delays' : fields.integer('Remind delays', + help="The number of days after which the user assigned to a manual goal will be reminded. Never reminded if no value is specified.") } _defaults = { diff --git a/addons/gamification/view/plan.xml b/addons/gamification/view/plan.xml index 109b8ef3319..123513fe9f6 100644 --- a/addons/gamification/view/plan.xml +++ b/addons/gamification/view/plan.xml @@ -74,6 +74,7 @@ +
From 48fed40b103544200e041749f5b1519a7db795c6 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Tue, 19 Feb 2013 17:56:09 +0100 Subject: [PATCH 036/521] [IMP] gamification: differenciate inprogress and inprogress to update bzr revid: mat@openerp.com-20130219165609-q7gqbuf0wm7v8egl --- addons/gamification/goal.py | 1 + addons/gamification/view/goal.xml | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/addons/gamification/goal.py b/addons/gamification/goal.py index bc0057a6613..0ffb77da3b3 100644 --- a/addons/gamification/goal.py +++ b/addons/gamification/goal.py @@ -23,6 +23,7 @@ from openerp.osv import fields, osv GAMIFICATION_GOAL_STATE = [ ('inprogress', 'In progress'), + ('inprogress_update', 'In progress (to update)'), ('reached', 'Reached'), ('failed', 'Failed'), ] diff --git a/addons/gamification/view/goal.xml b/addons/gamification/view/goal.xml index a788fdecd87..8c695d68d53 100644 --- a/addons/gamification/view/goal.xml +++ b/addons/gamification/view/goal.xml @@ -41,10 +41,10 @@
-
@@ -90,7 +90,7 @@ + domain="[('user_id', '=', uid),('state', 'in', ('inprogress', 'inprogress_update'))]"/> From 55541a3d3b4984a80b45e40ce06b5af5e86366dc Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Wed, 20 Feb 2013 13:33:28 +0100 Subject: [PATCH 037/521] [REF] gamification: minor changes for better consistency bzr revid: mat@openerp.com-20130220123328-n13psgprp4ci14vn --- addons/gamification/goal.py | 139 ++++++++++++++++-------------- addons/gamification/view/goal.xml | 13 ++- addons/gamification/view/plan.xml | 29 +++---- addons/gamification/view/type.xml | 6 +- 4 files changed, 98 insertions(+), 89 deletions(-) diff --git a/addons/gamification/goal.py b/addons/gamification/goal.py index 0ffb77da3b3..ba452d7636f 100644 --- a/addons/gamification/goal.py +++ b/addons/gamification/goal.py @@ -20,52 +20,7 @@ ############################################################################## from openerp.osv import fields, osv - -GAMIFICATION_GOAL_STATE = [ - ('inprogress', 'In progress'), - ('inprogress_update', 'In progress (to update)'), - ('reached', 'Reached'), - ('failed', 'Failed'), -] - -GAMIFICATION_PLAN_STATE = [ - ('draft', 'Draft'), - ('inprogress', 'In progress'), - ('done', 'Done'), -] - -GAMIFICATION_PERIOD_STATE = [ - ('once', 'Manual'), - ('daily', 'Daily'), - ('weekly', 'Weekly'), - ('monthly', 'Monthly'), - ('yearly', 'Yearly') -] - -GAMIFICATION_COMPUTATION_MODE = [ - ('sum','Sum'), - ('count','Count'), - ('manually','Manually') -] - -GAMIFICATION_VALIDATION_CONDITION = [ - ('minus','<='), - ('plus','>=') -] - -GAMIFICATION_REPORT_MODE = [ - ('board','Leader board'), - ('progressbar','Personal progressbar') -] - -GAMIFICATION_REPORT_FREQ = [ - ('never','Never'), - ('onchange','On change'), - ('daily','Daily'), - ('weekly','Weekly'), - ('monthly','Monthly'), - ('yearly', 'Yearly') -] +from openerp.tools.safe_eval import safe_eval class gamification_goal_type(osv.Model): @@ -82,7 +37,11 @@ class gamification_goal_type(osv.Model): _columns = { 'name': fields.char('Type Name', required=True), 'description': fields.text('Description'), - 'computation_mode': fields.selection(GAMIFICATION_COMPUTATION_MODE, + 'computation_mode': fields.selection([ + ('sum','Sum'), + ('count','Count'), + ('manually','Manually') + ], string="Mode of Computation", help="""How is computed the goal value :\n - 'Sum' for the total of the values if the 'Evaluated field'\n @@ -101,7 +60,10 @@ class gamification_goal_type(osv.Model): 'domain': fields.char("Domain", help="Technical filters rules to apply", required=True), # how to apply it ? - 'condition' : fields.selection(GAMIFICATION_VALIDATION_CONDITION, + 'condition' : fields.selection([ + ('minus','<='), + ('plus','>=') + ], string='Validation Condition', help='A goal is considered as completed when the current value is compared to the value to reach', required=True), @@ -118,6 +80,15 @@ class gamification_goal_type(osv.Model): 'domain':"[]", } + + +def compute_goal_completeness(current, target_goal): + # more than 100% case is handled by the widget + if target_goal > 0: + return 100.0 * current / target_goal + else: + return 0.0 + class gamification_goal(osv.Model): """Goal instance for a user @@ -131,11 +102,7 @@ class gamification_goal(osv.Model): def _get_completeness(self, cr, uid, ids, field_name, arg, context=None): res = {} for goal in self.browse(cr, uid, ids, context): - # more than 100% case is handled by the widget - if goal.target_goal > 0: - res[goal.id] = 100.0 * goal.current / goal.target_goal - else: - res[goal.id] = 0.0 + res[goal.id] = compute_goal_completeness(goal.current, goal.target_goal) return res _columns = { @@ -144,7 +111,7 @@ class gamification_goal(osv.Model): required=True, ondelete="cascade"), 'user_id' : fields.many2one('res.users', string='User', required=True), - 'plan_id' : fields.many2one('gamification.goal.plan', + 'planline_id' : fields.many2one('gamification.goal.planline', string='Goal Plan', ondelete="cascade"), 'start_date' : fields.date('Start Date'), @@ -157,8 +124,14 @@ class gamification_goal(osv.Model): track_visibility = 'always'), 'completeness': fields.function(_get_completeness, type='float', - string='Occupation'), - 'state': fields.selection(GAMIFICATION_GOAL_STATE, + string='Completeness'), + 'state': fields.selection([ + ('inprogress', 'In progress'), + ('inprogress_update', 'In progress (to update)'), + ('reached', 'Reached'), + ('failed', 'Failed'), + ('canceled', 'Canceled'), + ], string='State', required=True, track_visibility = 'always'), @@ -210,18 +183,38 @@ class gamification_goal_plan(osv.Model): 'autojoin_group_id' : fields.many2one('res.groups', string='Group', help='Group of users whose members will automatically be added to the users'), - 'period' : fields.selection(GAMIFICATION_PERIOD_STATE, - string='Period', + 'period' : fields.selection([ + ('once', 'Manual'), + ('daily', 'Daily'), + ('weekly', 'Weekly'), + ('monthly', 'Monthly'), + ('yearly', 'Yearly') + ], + string='Periodicity', help='Period of automatic goal assigment, will be done manually if none is selected', required=True), - 'state': fields.selection(GAMIFICATION_PLAN_STATE, + 'state': fields.selection([ + ('draft', 'Draft'), + ('inprogress', 'In progress'), + ('done', 'Done'), + ], string='State', required=True), - 'report_mode':fields.selection(GAMIFICATION_REPORT_MODE, - string="Mode", - help='How is displayed the results, shared or in a signle progressbar', + 'visibility_mode':fields.selection([ + ('board','Leader board'), + ('progressbar','Personal progressbar') + ], + string="Visibility", + help='How are displayed the results, shared or in a single progressbar', required=True), - 'report_message_frequency':fields.selection(GAMIFICATION_REPORT_FREQ, + 'report_message_frequency':fields.selection([ + ('never','Never'), + ('onchange','On change'), + ('daily','Daily'), + ('weekly','Weekly'), + ('monthly','Monthly'), + ('yearly', 'Yearly') + ], string="Frequency", required=True), 'report_message_group_id' : fields.many2one('mail.group', @@ -235,7 +228,7 @@ class gamification_goal_plan(osv.Model): _defaults = { 'period': 'once', 'state': 'draft', - 'report_mode' : 'progressbar', + 'visibility_mode' : 'progressbar', 'report_message_frequency' : 'onchange', } @@ -287,6 +280,24 @@ class gamification_goal_plan(osv.Model): return self.write(cr, uid, ids, {'state': 'inprogress'}, context=context) + def generate_goals_from_plan(self, cr, uid, ids, context=None): + """Generate the lsit of goals fron a plan""" + for plan in self.browse(cr, uid, ids, context): + for planline in plan.planline_ids: + for user in plan.user_ids: + goal_obj = self.pool.get('gamification.goal') + current = compute_current_value(planline.type_id, user_id) + goal_id = goal_obj.create(cr, uid, { + 'type_id': planline.type_id, + 'user_id': user.id, + 'start_date':0, + 'end_date':0, + 'target_goal':planline.target_goal, + 'state':'inprogress', + 'last_update':fields.date.today, + }, context=context) + + class gamification_goal_planline(osv.Model): """Gamification goal planline diff --git a/addons/gamification/view/goal.xml b/addons/gamification/view/goal.xml index 8c695d68d53..20a30607359 100644 --- a/addons/gamification/view/goal.xml +++ b/addons/gamification/view/goal.xml @@ -5,7 +5,6 @@ Goals gamification.goal tree,form,calendar - {'search_default_my_in_progress': 1}

Click to create a goal. @@ -30,7 +29,7 @@ - + @@ -41,7 +40,8 @@

-
@@ -58,6 +58,7 @@ + From 0cc2ab390e586df29ea941cec2512e7d5cf50354 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Thu, 21 Feb 2013 14:50:52 +0100 Subject: [PATCH 046/521] [FIX] gamification: days and not day bzr revid: mat@openerp.com-20130221135052-yh4mu7huzjab04tt --- addons/gamification/cron.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/gamification/cron.xml b/addons/gamification/cron.xml index b222d0e6d8c..d1ca200111e 100644 --- a/addons/gamification/cron.xml +++ b/addons/gamification/cron.xml @@ -7,7 +7,7 @@ Run Goal Checker 1 - day + days -1 gamification.goal @@ -20,7 +20,7 @@ Run Goal Plan Checker 1 - day + days -1 gamification.goal.plan From 14d9a9b573ad6f76aa34fcdd8046bb3ecc15ef1e Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 22 Feb 2013 10:47:45 +0100 Subject: [PATCH 047/521] [IMP] gamification: minor improvements and fix bzr revid: mat@openerp.com-20130222094745-jxe0m4i11qbbe1vp --- addons/gamification/cron.xml | 5 ++--- addons/gamification/goal.py | 26 ++++++++++++++++---------- addons/gamification/view/goal.xml | 9 +++++++-- addons/gamification/view/plan.xml | 12 ++++++------ 4 files changed, 31 insertions(+), 21 deletions(-) diff --git a/addons/gamification/cron.xml b/addons/gamification/cron.xml index d1ca200111e..4388ac88ff9 100644 --- a/addons/gamification/cron.xml +++ b/addons/gamification/cron.xml @@ -5,7 +5,6 @@ Run Goal Checker - 1 days -1 @@ -15,10 +14,9 @@ () - Run Goal Plan Checker - 1 days -1 @@ -27,5 +25,6 @@ _update_all () + \ No newline at end of file diff --git a/addons/gamification/goal.py b/addons/gamification/goal.py index aa9bf282788..c40a67b4eee 100644 --- a/addons/gamification/goal.py +++ b/addons/gamification/goal.py @@ -167,8 +167,7 @@ class gamification_goal(osv.Model): def _update_all(self, cr, uid, ids=False, context=None): """Update every goal in progress""" if not ids: - ids = self.search(cr, uid, [('state', 'in', ('inprogress','inprogress_update'))]) - print("_update_all", ids) + ids = self.search(cr, uid, [('state', 'in', ('inprogress','inprogress_update', 'reached'))]) return self.update(cr, uid, ids, context=context) def update(self, cr, uid, ids, context=None, force_update=False): @@ -180,11 +179,16 @@ class gamification_goal(osv.Model): :param force_update: if false, only goals in progress are checked.""" for goal in self.browse(cr, uid, ids, context=context or {}): - if not force_update and goal.state not in ('inprogress','inprogress_update'): # reached ? + if not force_update and goal.state not in ('inprogress','inprogress_update','reached'): + # skip if goal failed or canceled + continue + if goal.state == 'reached' and goal.end_date and fields.date.today() > goal.end_date: + # only a goal reached but not passed the end date will still be + # checked (to be able to improve the score) continue if goal.type_id.computation_mode == 'manually': - towrite = {'current': current} + towrite = {'current':goal.current} # check for remind to update if goal.remind_update_delay and goal.last_update: delta_max = timedelta(days=goal.remind_update_delay) @@ -195,8 +199,8 @@ class gamification_goal(osv.Model): obj = self.pool.get(goal.type_id.model_id.model) field_date_name = goal.type_id.field_date_id.name - domain = safe_eval(goal.type_id.domain) - domain.append(('user_id', '=', goal.user_id.id)) + domain = safe_eval(goal.type_id.domain, + {'user_id': goal.user_id.id}) if goal.start_date: domain.append((field_date_name, '>=', goal.start_date)) if goal.end_date: @@ -244,10 +248,11 @@ class gamification_goal(osv.Model): ('user_id', '=', user_id), ('start_date', '=', start_date.isoformat())] goal_ids = obj.search(cr, uid, domain, context=context) + print(domain, goal_ids) if len(goal_ids) > 0: # already exist, skip return True - + print("creating goal for", planline_id, user_id, start_date) planline = self.pool.get('gamification.goal.planline').browse(cr, uid, planline_id, context) values = { 'type_id':planline.type_id.id, @@ -327,7 +332,7 @@ class gamification_goal_plan(osv.Model): string='Group', help='Group of users whose members will automatically be added to the users'), 'period' : fields.selection([ - ('once', 'Manual'), + ('once', 'No Periodicity'), ('daily', 'Daily'), ('weekly', 'Weekly'), ('monthly', 'Monthly'), @@ -397,8 +402,9 @@ class gamification_goal_plan(osv.Model): def _update_all(self, cr, uid, ids=False, context=None): """Update every plan in progress""" if not ids: - ids = self.search(cr, uid, [('state', '=', 'inprogress')]) - print("_update_all", ids) + ids = self.search(cr, uid, [('state', '=', 'inprogress'), + ('period', '!=', 'once')]) + print("_update_all plans", ids) return self.generate_goals_from_plan(cr, uid, ids, context=context) def action_start(self, cr, uid, ids, context=None): diff --git a/addons/gamification/view/goal.xml b/addons/gamification/view/goal.xml index 9c641de2711..ed964452d9e 100644 --- a/addons/gamification/view/goal.xml +++ b/addons/gamification/view/goal.xml @@ -20,7 +20,7 @@ Goal List gamification.goal - + @@ -57,7 +57,12 @@ - + + diff --git a/addons/gamification/view/plan.xml b/addons/gamification/view/plan.xml index e83ca145124..66af613c2fd 100644 --- a/addons/gamification/view/plan.xml +++ b/addons/gamification/view/plan.xml @@ -53,12 +53,12 @@ -

-
-
- -

+
+
From be75098490cb7b59664eaef2d299237eef231212 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 22 Feb 2013 10:56:15 +0100 Subject: [PATCH 048/521] [REF] gamification: remove force_update parameter bzr revid: mat@openerp.com-20130222095615-r79xrz3awc886ko6 --- addons/gamification/goal.py | 15 +++++---------- addons/gamification/view/goal.xml | 2 +- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/addons/gamification/goal.py b/addons/gamification/goal.py index c40a67b4eee..95341d4a004 100644 --- a/addons/gamification/goal.py +++ b/addons/gamification/goal.py @@ -170,16 +170,15 @@ class gamification_goal(osv.Model): ids = self.search(cr, uid, [('state', 'in', ('inprogress','inprogress_update', 'reached'))]) return self.update(cr, uid, ids, context=context) - def update(self, cr, uid, ids, context=None, force_update=False): + def update(self, cr, uid, ids, context=None): """Update the goals to recomputes values and change of states If a goal reaches the target value, the status is set to reach If the end date is passed (at least +1 day, time not considered) without - the target value being reached, the goal is set as failed - :param force_update: if false, only goals in progress are checked.""" + the target value being reached, the goal is set as failed.""" for goal in self.browse(cr, uid, ids, context=context or {}): - if not force_update and goal.state not in ('inprogress','inprogress_update','reached'): + if goal.state not in ('inprogress','inprogress_update','reached'): # skip if goal failed or canceled continue if goal.state == 'reached' and goal.end_date and fields.date.today() > goal.end_date: @@ -277,7 +276,7 @@ class gamification_goal(osv.Model): values['remind_update_delay'] = planline.plan_id.remind_update_delay new_goal_id = obj.create(cr, uid, values, context) - self.update(cr, uid, [new_goal_id], context=context, force_update=True) + self.update(cr, uid, [new_goal_id], context=context) def cancel_goals_from_plan(self, cr, uid, ids, planline_id, context=None): @@ -299,10 +298,6 @@ class gamification_goal(osv.Model): def action_cancel(self, cr, uid, ids, context=None): return self.write(cr, uid, ids, {'state': 'inprogress'}, context=context) - def action_refresh(self, cr, uid, ids, context=None): - """Update the state of goal, force to recomputes values""" - return self.update(cr, uid, ids, context=context, force_update=True) - class gamification_goal_plan(osv.Model): """Gamification goal plan @@ -427,7 +422,7 @@ class gamification_goal_plan(osv.Model): for planline in plan.planline_ids: goal_obj = self.pool.get('gamification.goal') goal_ids = goal_obj.search(cr, uid, [('planline_id', '=', planline.id)] , context=context) - goal_obj.update(cr, uid, goal_ids, context=context, force_update=True) + goal_obj.update(cr, uid, goal_ids, context=context) return True diff --git a/addons/gamification/view/goal.xml b/addons/gamification/view/goal.xml index ed964452d9e..a66af16d6a9 100644 --- a/addons/gamification/view/goal.xml +++ b/addons/gamification/view/goal.xml @@ -40,7 +40,7 @@
-
+ ]]>
+ + + From d9999731f74ef031f25b11aa893160f28ba3b4af Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Tue, 26 Feb 2013 12:34:03 +0100 Subject: [PATCH 054/521] [ADD] gamification: send email for individual report bzr revid: mat@openerp.com-20130226113403-2hw21ush1gw1kis0 --- addons/gamification/__init__.py | 3 +- addons/gamification/goal.py | 49 +++++++++++-------- .../gamification/report/report_progress.xml | 25 ++++------ addons/gamification/res_users.py | 2 - addons/gamification/view/plan.xml | 1 + 5 files changed, 41 insertions(+), 39 deletions(-) diff --git a/addons/gamification/__init__.py b/addons/gamification/__init__.py index a406bf3a621..540d22424d0 100644 --- a/addons/gamification/__init__.py +++ b/addons/gamification/__init__.py @@ -1,2 +1,3 @@ import goal -import res_users \ No newline at end of file +import res_users +import report diff --git a/addons/gamification/goal.py b/addons/gamification/goal.py index b01553ab768..ba9f665188c 100644 --- a/addons/gamification/goal.py +++ b/addons/gamification/goal.py @@ -2,26 +2,28 @@ ############################################################################## # # OpenERP, Open Source Management Solution -# Copyright (C) 2004-2013 Tiny SPRL (). +# Copyright (C) 2010-Today 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. +# 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 Affero General Public License for more details. +# GNU 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 . +# You should have received a copy of the GNU General Public License +# along with this program. If not, see # ############################################################################## from openerp.osv import fields, osv from openerp.tools.safe_eval import safe_eval +from mako.template import Template as MakoTemplate + from datetime import date, timedelta import calendar import itertools @@ -476,7 +478,6 @@ class gamification_goal_plan(osv.Model): :param ids: ids of plans to which the users will be added :param user_ids: ids of the users to add""" - print("subscibe users", ids, user_ids) for plan in self.browse(cr,uid, ids, context): subscription = [user.id for user in plan.user_ids] subscription.extend(user_ids) @@ -489,21 +490,30 @@ class gamification_goal_plan(osv.Model): """Post report about the progress of the goals""" goal_obj = self.pool.get('gamification.goal') - + for plan in self.browse(cr, uid, ids, context=context): if plan.visibility_mode == 'board': # generate a shared report pass else: + if not plan.report_message_group_id: + continue + # generate individual reports - report_title = "Individual Report for {0} - {1}".format(plan.name, fields.date.today()) + template_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'gamification', 'email_template_gamification_individual')[1] + for user in plan.user_ids: + goal_ids = self.get_current_related_user_goals(cr, uid, plan.id, user.id, context) + if len(goal_ids) == 0: + continue + + template_context = dict(context) + template_context['goals'] = goal_obj.browse(cr, uid, goal_ids, context=context) + template_context['user'] = user + self.pool.get('email.template').send_mail(cr, uid, template_id, plan.id, context=template_context) - for goal in goal_obj.browse(cr, uid, goal_ids, context=context): - pass - def get_current_related_user_goals(self, cr, uid, plan_id, user_id, context=None): """Get the ids of goals linked to a plan for the current instance @@ -512,7 +522,7 @@ class gamification_goal_plan(osv.Model): return the goals started the 1st of this month). """ - plan in self.browse(cr, uid, plan_id, context=context) + plan = self.browse(cr, uid, plan_id, context=context) today = date.today() if plan.period == 'daily': start_date = today @@ -542,11 +552,13 @@ class gamification_goal_plan(osv.Model): related_goal_ids.append(goal_ids[0]) elif len(goal_ids) == 0: # this goal has been deleted - raise osv.except_osv(_('Warning!'), _('Planline {0} has no goal present for user {1} at date {2}'.format(planline.id, user.id, start_date))) + raise osv.except_osv('Warning!','Planline {0} has no goal present for user {1} at date {2}'.format(planline.id, user.id, start_date)) else: # more than one goal ? - raise osv.except_osv(_('Warning!'), _('Duplicate goals for planline {0}, user {1}, date {2}'.format(planline.id, user.id, start_date))) + raise osv.except_osv('Warning!', 'Duplicate goals for planline {0}, user {1}, date {2}'.format(planline.id, user.id, start_date)) related_goal_ids.extend(goal_ids) + return related_goal_ids + class gamification_goal_planline(osv.Model): """Gamification goal planline @@ -589,7 +601,4 @@ class gamification_goal_planline(osv.Model): store={ 'gamification.goal.type': (_get_planline_types, ['sequence'], 10), }), - } - -# class gamification_goal_report(osv.Model): -# _name = 'gamification.goal.report' + } \ No newline at end of file diff --git a/addons/gamification/report/report_progress.xml b/addons/gamification/report/report_progress.xml index 67d7e564098..b8a2c3b22db 100644 --- a/addons/gamification/report/report_progress.xml +++ b/addons/gamification/report/report_progress.xml @@ -8,30 +8,23 @@ form form,tree - - - - - + - + Individual Report - Send by Email noreply@localhost - ${object.title} - ${object.partner_id.id} - + Individual report - ${object.name} + ${object.report_message_group_id.alias_id.name_get()[0][1]} + - Individual_Report_${(object.number or '').replace('/','_')}_${object.state == 'draft' and 'draft' or ''} +
+

Individual report - ${object.name}

-

${report.title}

- -

Hello ${report.user}, bellow are your latest results for the plan ${report.plan_name}.

+

Hello ${ctx['user'].name}, bellow are your latest results for the plan ${object.name}.

@@ -40,7 +33,7 @@ - % for goal in report: + % for goal in ctx['goals']: diff --git a/addons/gamification/res_users.py b/addons/gamification/res_users.py index f2f54d9b324..38d4950b185 100644 --- a/addons/gamification/res_users.py +++ b/addons/gamification/res_users.py @@ -9,7 +9,6 @@ class res_users_gamification_group(osv.Model): _inherit = ['res.users'] def write(self, cr, uid, ids, vals, context=None): - print("Overwrite res_users_gamification_group", ids) write_res = super(res_users_gamification_group, self).write(cr, uid, ids, vals, context=context) if vals.get('groups_id'): # form: {'group_ids': [(3, 10), (3, 3), (4, 10), (4, 3)]} or {'group_ids': [(6, 0, [ids]} @@ -31,7 +30,6 @@ class res_groups_gamification_group(osv.Model): _inherit = 'res.groups' def write(self, cr, uid, ids, vals, context=None): - print("Overwrite res_groups_gamification_group", ids) write_res = super(res_groups_gamification_group, self).write(cr, uid, ids, vals, context=context) if vals.get('users'): # form: {'group_ids': [(3, 10), (3, 3), (4, 10), (4, 3)]} or {'group_ids': [(6, 0, [ids]} diff --git a/addons/gamification/view/plan.xml b/addons/gamification/view/plan.xml index 66af613c2fd..f4b3313c76e 100644 --- a/addons/gamification/view/plan.xml +++ b/addons/gamification/view/plan.xml @@ -50,6 +50,7 @@
Current Completeness
${goal.type_id.name} ${goal.target_goal}
@@ -43,6 +43,43 @@ % endfor
+
+ ]]>
+
+ + + + Leaderboard Goal Report - Send by Email + noreply@localhost + ${object.name} group report + ${object.report_message_group_id.alias_id.name_get()[0][1]} + + + +

Group report - ${object.name}

+ +

Hello, + + Bellow are the latest results for the plan ${object.name} for the group ${object.report_message_group_id.name}

+ + % for planline in ctx['planlines']: +

${planline['goal_type']}

+ + + + + + % for idx, goal in planline['list']: + + + + + + % endfor +
#UserCompletenessCurrent
${idx+1}${goal.completeness}${goal.current}/${goal.target_goal}
+ % endfor + ]]>
From 5a341ab9708f74e93c4f29593256a46a79a63275 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Tue, 26 Feb 2013 16:13:28 +0100 Subject: [PATCH 057/521] [FIX] gamification: add user name in report board bzr revid: mat@openerp.com-20130226151328-4lnq7ku5y8waedkl --- addons/gamification/report/report_progress.xml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/addons/gamification/report/report_progress.xml b/addons/gamification/report/report_progress.xml index 5027cf5e877..08fa3cad3c8 100644 --- a/addons/gamification/report/report_progress.xml +++ b/addons/gamification/report/report_progress.xml @@ -71,9 +71,14 @@ Completeness Current % for idx, goal in planline['list']: - + = 100: + style="font-weight:bold;"" + % endif + > ${idx+1} - ${goal.completeness} + ${goal.user.name} + ${goal.completeness}% ${goal.current}/${goal.target_goal} % endfor From 240ed326b20f6a4303380b011c4634d9a81e3326 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Tue, 26 Feb 2013 16:23:25 +0100 Subject: [PATCH 058/521] [IMP] gamification: overwrite write method for goal bzr revid: mat@openerp.com-20130226152325-5n3ruxk6jsju18uu --- addons/gamification/goal.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/addons/gamification/goal.py b/addons/gamification/goal.py index de7f74462b1..2491f474c26 100644 --- a/addons/gamification/goal.py +++ b/addons/gamification/goal.py @@ -272,6 +272,13 @@ class gamification_goal(osv.Model): return self.write(cr, uid, ids, {'state': 'inprogress'}, context=context) + def write(self, cr, uid, ids, vals, context=None): + for goal in self.browse(cr, uid, ids, vals): + vals['last_update'] = fields.date.today() + write_res = super(gamification_goal, self).write(cr, uid, ids, vals, context=context) + return write_res + + class gamification_goal_plan(osv.Model): """Gamification goal plan @@ -536,7 +543,7 @@ class gamification_goal_plan(osv.Model): # most complete first, current if same percentage (eg: if several 100%) sorted_planline_goals = enumerate(sorted(planlines_stats, key=lambda k: (k['completeness'], k['current']), reverse=True)) template_context['planlines'].append({'goal_type':planline.type_id.name, 'list':sorted_planline_goals}) - + self.pool.get('email.template').send_mail(cr, uid, template_id, plan.id, context=template_context) else: From 6cc39b566ad46ce4bc9775c74dda97e1563b981e Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Tue, 26 Feb 2013 16:32:47 +0100 Subject: [PATCH 059/521] [ADD] gamification: refresh button for manual goal bzr revid: mat@openerp.com-20130226153247-ak48q3dooyc71doi --- addons/gamification/goal.py | 3 ++- addons/gamification/view/goal.xml | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/gamification/goal.py b/addons/gamification/goal.py index 2491f474c26..fedf4c7ea36 100644 --- a/addons/gamification/goal.py +++ b/addons/gamification/goal.py @@ -273,8 +273,9 @@ class gamification_goal(osv.Model): def write(self, cr, uid, ids, vals, context=None): + """Overwrite the write method to update the last_update field to today""" for goal in self.browse(cr, uid, ids, vals): - vals['last_update'] = fields.date.today() + vals['last_update'] = fields.date.today() write_res = super(gamification_goal, self).write(cr, uid, ids, vals, context=context) return write_res diff --git a/addons/gamification/view/goal.xml b/addons/gamification/view/goal.xml index 926d02f9c71..52def276977 100644 --- a/addons/gamification/view/goal.xml +++ b/addons/gamification/view/goal.xml @@ -47,6 +47,9 @@ +
+
From ce777dde1cdea831edfc6dee7e3ff212b973353a Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Wed, 27 Feb 2013 09:46:08 +0100 Subject: [PATCH 060/521] [IMP] gamification: better consistency for plan bzr revid: mat@openerp.com-20130227084608-79t5fyjzweq5zq1j --- addons/gamification/goal.py | 20 ++++++++++++---- addons/gamification/view/plan.xml | 38 ++++++++++++++++++++++++++----- 2 files changed, 47 insertions(+), 11 deletions(-) diff --git a/addons/gamification/goal.py b/addons/gamification/goal.py index fedf4c7ea36..32186ff0a15 100644 --- a/addons/gamification/goal.py +++ b/addons/gamification/goal.py @@ -305,7 +305,7 @@ class gamification_goal_plan(osv.Model): help="list of goals that will be set", required=True), 'autojoin_group_id' : fields.many2one('res.groups', - string='Group', + string='Auto-join Group', help='Group of users whose members will automatically be added to the users'), 'period' : fields.selection([ ('once', 'No Periodicity'), @@ -342,8 +342,8 @@ class gamification_goal_plan(osv.Model): string="Frequency", required=True), 'report_message_group_id' : fields.many2one('mail.group', - string='Report to', - help='Group that will receive the report in addition to the user'), + 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'), 'remind_update_delay' : fields.integer('Remind delay', help="The number of days after which the user assigned to a manual goal will be reminded. Never reminded if no value is specified.") @@ -375,6 +375,16 @@ class gamification_goal_plan(osv.Model): (_check_nonzero_users, "At least one user is required to create a non-draft goal plan", ['user_ids']), ] + def write(self, cr, uid, ids, vals, context=None): + """Overwrite the write method to add the user of groups""" + write_res = super(gamification_goal_plan, self).write(cr, uid, ids, vals, context=context) + + # add users when change the group auto-subscription + if 'autojoin_group_id' in vals: + new_group = self.pool.get('res.groups').browse(cr, uid, vals['autojoin_group_id'], context=context) + self.plan_subscribe_users(cr, uid, ids, [user.id for user in new_group.users], context=context) + return write_res + def _update_all(self, cr, uid, ids=False, context=None): """Update every plan in progress""" if not ids: @@ -487,7 +497,7 @@ class gamification_goal_plan(osv.Model): return True - def plan_subscribe_users(self, cr, uid, ids, user_ids, context=None): + def plan_subscribe_users(self, cr, uid, ids, new_user_ids, context=None): """ Add the following users to plans :param ids: ids of plans to which the users will be added @@ -495,7 +505,7 @@ class gamification_goal_plan(osv.Model): for plan in self.browse(cr,uid, ids, context): subscription = [user.id for user in plan.user_ids] - subscription.extend(user_ids) + subscription.extend(new_user_ids) unified_subscription = list(set(subscription)) self.write(cr, uid, ids, {'user_ids': [(4, uid) for uid in unified_subscription]}, context=context) return True diff --git a/addons/gamification/view/plan.xml b/addons/gamification/view/plan.xml index f4b3313c76e..ce2e60c5d1e 100644 --- a/addons/gamification/view/plan.xml +++ b/addons/gamification/view/plan.xml @@ -70,12 +70,38 @@ - + - - - - + + @@ -90,7 +116,7 @@ - + From 86bb3fbb2a814879df99d60196eb914a9d426175 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Wed, 27 Feb 2013 10:42:13 +0100 Subject: [PATCH 061/521] [FIX] gamification: show related goals from plan correctly bzr revid: mat@openerp.com-20130227094213-jbhg1g5xiv1va2fz --- addons/gamification/goal.py | 29 ++++++++++++++++++++++++++--- addons/gamification/view/plan.xml | 5 ++--- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/addons/gamification/goal.py b/addons/gamification/goal.py index 32186ff0a15..3776b008e56 100644 --- a/addons/gamification/goal.py +++ b/addons/gamification/goal.py @@ -447,6 +447,29 @@ class gamification_goal_plan(osv.Model): return True + def action_show_related_goals(self, cr, uid, ids, context=None): + """ This opens goal view with a restriction to the list of goals from this plan only + @return: the goal view + """ + # get ids of related goals + goal_obj = self.pool.get('gamification.goal') + related_goal_ids = [] + for plan in self.browse(cr, uid, ids, context=context): + for planline in plan.planline_ids: + goal_ids = goal_obj.search(cr, uid, [('planline_id', '=', planline.id)], context=context) + related_goal_ids.extend(goal_ids) + + # process the new view + if context is None: + context = {} + res = self.pool.get('ir.actions.act_window').for_xml_id(cr, uid ,'gamification','goals_from_plan_act', context=context) + res['context'] = context + res['context'].update({ + 'default_id': related_goal_ids + }) + res['domain'] = [('id','in', related_goal_ids)] + return res + def generate_goals_from_plan(self, cr, uid, ids, context=None): """Generate the lsit of goals fron a plan""" for plan in self.browse(cr, uid, ids, context): @@ -571,6 +594,7 @@ class gamification_goal_plan(osv.Model): self.pool.get('email.template').send_mail(cr, uid, template_id, plan.id, context=template_context) return True + def get_current_related_goals(self, cr, uid, plan_id, user_id, context=None): """Get the ids of goals linked to a plan for the current instance @@ -593,9 +617,8 @@ class gamification_goal_plan(osv.Model): domain.append(('start_date', '=', start_date.isoformat())) goal_ids = goal_obj.search(cr, uid, domain, context=context) - if len(goal_ids) == 1: - related_goal_ids.append(goal_ids[0]) - elif len(goal_ids) == 0: + related_goal_ids.append(goal_ids[0]) + if len(goal_ids) == 0: # this goal has been deleted raise osv.except_osv('Warning!','Planline {0} has no goal present for user {1} at date {2}'.format(planline.id, user.id, start_date)) else: # more than one goal ? diff --git a/addons/gamification/view/plan.xml b/addons/gamification/view/plan.xml index ce2e60c5d1e..265deaaecd8 100644 --- a/addons/gamification/view/plan.xml +++ b/addons/gamification/view/plan.xml @@ -31,12 +31,11 @@
- + gamification.goal form Related Goals tree,form - {'search_default_plan_id': [active_id], 'default_plan_id': active_id} @@ -63,7 +62,7 @@
-
From 504b6c4ca7e29afe04f216519b982ed1f986a0f2 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Wed, 27 Feb 2013 11:59:56 +0100 Subject: [PATCH 062/521] [ADD] gamification: send reminder for update bzr revid: mat@openerp.com-20130227105956-pu0xjsswucjou5o9 --- addons/gamification/__openerp__.py | 1 + addons/gamification/goal.py | 26 ++++++++++--------- addons/gamification/report/reminder.xml | 23 ++++++++++++++++ .../gamification/report/report_progress.xml | 11 -------- addons/gamification/view/goal.xml | 2 +- 5 files changed, 39 insertions(+), 24 deletions(-) create mode 100644 addons/gamification/report/reminder.xml diff --git a/addons/gamification/__openerp__.py b/addons/gamification/__openerp__.py index 855a18cb749..26cc1696fc2 100644 --- a/addons/gamification/__openerp__.py +++ b/addons/gamification/__openerp__.py @@ -33,6 +33,7 @@ 'view/menu.xml', 'cron.xml', 'report/report_progress.xml', + 'report/reminder.xml', ], 'installable': True, 'application': True, diff --git a/addons/gamification/goal.py b/addons/gamification/goal.py index 3776b008e56..704ba2bad11 100644 --- a/addons/gamification/goal.py +++ b/addons/gamification/goal.py @@ -24,7 +24,7 @@ from openerp.tools.safe_eval import safe_eval from mako.template import Template as MakoTemplate -from datetime import date, timedelta +from datetime import date, datetime, timedelta import calendar import itertools @@ -115,13 +115,6 @@ class gamification_goal_type(osv.Model): -def compute_goal_completeness(current, target_goal): - # more than 100% case is handled by the widget - if target_goal > 0: - return 100.0 * current / target_goal - else: - return 0.0 - class gamification_goal(osv.Model): """Goal instance for a user @@ -132,9 +125,14 @@ class gamification_goal(osv.Model): _inherit = 'mail.thread' def _get_completeness(self, cr, uid, ids, field_name, arg, context=None): + """Return the percentage of completeness of the goal, between 0 and 100""" res = {} for goal in self.browse(cr, uid, ids, context): - res[goal.id] = compute_goal_completeness(goal.current, goal.target_goal) + if goal.current > 0: + res[goal.id] = min(100, round(100.0 * goal.current / goal.target_goal, 2)) + else: + res[goal.id] = 0.0 + return res def on_change_type_id(self, cr, uid, ids, type_id=False, context=None): @@ -194,7 +192,6 @@ class gamification_goal(osv.Model): } - def _update_all(self, cr, uid, ids=False, context=None): """Update every goal in progress""" if not ids: @@ -208,7 +205,7 @@ class gamification_goal(osv.Model): If a goal reaches the target value, the status is set to reach If the end date is passed (at least +1 day, time not considered) without the target value being reached, the goal is set as failed.""" - + for goal in self.browse(cr, uid, ids, context=context or {}): if goal.state not in ('inprogress','inprogress_update','reached'): # skip if goal failed or canceled @@ -223,9 +220,14 @@ class gamification_goal(osv.Model): # check for remind to update if goal.remind_update_delay and goal.last_update: delta_max = timedelta(days=goal.remind_update_delay) - if fields.date.today() - goal.last_update > delta_max: + last_update = datetime.strptime(goal.last_update,'%Y-%m-%d').date() + if date.today() - last_update > delta_max: towrite['state'] = 'inprogress_update' + # generate a remind report + template_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'gamification', 'email_template_goal_reminder')[1] + self.pool.get('email.template').send_mail(cr, uid, template_id, goal.id, context=context) + else: # count or sum obj = self.pool.get(goal.type_id.model_id.model) field_date_name = goal.type_id.field_date_id.name diff --git a/addons/gamification/report/reminder.xml b/addons/gamification/report/reminder.xml new file mode 100644 index 00000000000..d184b6518de --- /dev/null +++ b/addons/gamification/report/reminder.xml @@ -0,0 +1,23 @@ + + + + + Goal Update Reminder - Send by Email + noreply@localhost + Goal Update Reminder + ${object.user_id.email} + + + +

Hello ${object.user_id.name}

+ +

You have not updated your progress for the goal ${object.type_id.name} (currently reached at ${object.completeness}%) for at least ${object.remind_update_delay}. 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.

+ + ]]>
+
+ +
+
diff --git a/addons/gamification/report/report_progress.xml b/addons/gamification/report/report_progress.xml index 08fa3cad3c8..08e37df1dec 100644 --- a/addons/gamification/report/report_progress.xml +++ b/addons/gamification/report/report_progress.xml @@ -1,16 +1,5 @@ - - - - Email Templates - email.template - form - form,tree - - - - diff --git a/addons/gamification/view/goal.xml b/addons/gamification/view/goal.xml index 52def276977..c983076c9ad 100644 --- a/addons/gamification/view/goal.xml +++ b/addons/gamification/view/goal.xml @@ -48,7 +48,7 @@
-
From e57a761dc7ca0463b8dffac7d8423ec362745513 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Wed, 27 Feb 2013 12:12:20 +0100 Subject: [PATCH 063/521] [IMP] gamification: add start goal button for draft goals bzr revid: mat@openerp.com-20130227111220-ipgvl5djlndcnxpw --- addons/gamification/goal.py | 5 ++++- addons/gamification/view/goal.xml | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/gamification/goal.py b/addons/gamification/goal.py index 704ba2bad11..2b120eeaedf 100644 --- a/addons/gamification/goal.py +++ b/addons/gamification/goal.py @@ -208,7 +208,7 @@ class gamification_goal(osv.Model): for goal in self.browse(cr, uid, ids, context=context or {}): if goal.state not in ('inprogress','inprogress_update','reached'): - # skip if goal failed or canceled + # skip if goal draft, failed or canceled continue if goal.state == 'reached' and goal.end_date and fields.date.today() > goal.end_date: # only a goal reached but not passed the end date will still be @@ -263,6 +263,9 @@ class gamification_goal(osv.Model): self.write(cr, uid, [goal.id], towrite, context=context) return True + def action_start(self, cr, uid, ids, context=None): + self.write(cr, uid, ids, {'state': 'inprogress'}, context=context) + return self.update(cr, uid, ids, context=context) def action_reach(self, cr, uid, ids, context=None): return self.write(cr, uid, ids, {'state': 'reached'}, context=context) diff --git a/addons/gamification/view/goal.xml b/addons/gamification/view/goal.xml index c983076c9ad..a15e53a074e 100644 --- a/addons/gamification/view/goal.xml +++ b/addons/gamification/view/goal.xml @@ -40,7 +40,8 @@
-
-
-
@@ -69,9 +66,14 @@ - + - +
diff --git a/addons/gamification/view/plan.xml b/addons/gamification/view/plan.xml index 265deaaecd8..fbf4dc4a3e3 100644 --- a/addons/gamification/view/plan.xml +++ b/addons/gamification/view/plan.xml @@ -47,8 +47,8 @@ + +