diff --git a/addons/gamification/badge_view.xml b/addons/gamification/badge_view.xml index c6e08a9763a..32107402990 100644 --- a/addons/gamification/badge_view.xml +++ b/addons/gamification/badge_view.xml @@ -92,7 +92,7 @@ - + @@ -132,18 +132,7 @@
-

- - -

+

diff --git a/addons/gamification/goal.py b/addons/gamification/goal.py index eb8150f904f..6ee819a9610 100644 --- a/addons/gamification/goal.py +++ b/addons/gamification/goal.py @@ -335,6 +335,9 @@ class gamification_goal(osv.Model): for field_name in field_names[1:]: res = res.__getitem__(field_name) action['res_id'] = res + action['view_mode'] = 'form' # if one element to display, should see it in form mode + action['target'] = 'new' + print(action) return action except ValueError: _logger.warning("Invalid XML ID '%s' for goal action.", goal.type_id.action_id) @@ -349,8 +352,9 @@ class gamification_goal(osv.Model): } action['context'] = {'default_goal_id': goal_id, 'default_current': goal.current} action['res_model'] = 'gamification.goal.wizard' + print(action) return action - + print(False) return False def changed_users_avatar(self, cr, uid, ids, context): diff --git a/addons/gamification/goal_base_data.xml b/addons/gamification/goal_base_data.xml index 9665a4e1394..656758b630d 100644 --- a/addons/gamification/goal_base_data.xml +++ b/addons/gamification/goal_base_data.xml @@ -28,7 +28,7 @@ Specify at least a website count - [('user_ids', 'in', user_id),('website', '!=', 'www.yourcompany.com')] + [('user_ids', 'in', user_id), ('name', '!=', 'Your Company')] base.action_res_company_form_my company_id.id @@ -38,7 +38,7 @@ count [('user_ids', 'in', user_id),('logo', '!=', False)] - base.action_res_company_form_my + base.action_res_company_form company_id.id @@ -51,29 +51,6 @@ - - - - 1 - - - - 1 - - - - - 1 - - - - 1 - - - - 1 - - @@ -81,10 +58,8 @@ once progressbar never - - - + inprogress @@ -92,29 +67,38 @@ once progressbar never - - + inprogress - - + + + 1 + + 1 - + + + 1 - + + + 1 + + 1 + diff --git a/addons/gamification/goal_view.xml b/addons/gamification/goal_view.xml index 525a30bb6ae..c6ed02491df 100644 --- a/addons/gamification/goal_view.xml +++ b/addons/gamification/goal_view.xml @@ -112,7 +112,6 @@ - @@ -204,28 +203,29 @@
+ diff --git a/addons/gamification/plan.py b/addons/gamification/plan.py index 054148b7504..7819d38cb3b 100644 --- a/addons/gamification/plan.py +++ b/addons/gamification/plan.py @@ -168,25 +168,6 @@ class gamification_goal_plan(osv.Model): 'manager_id' : lambda s, cr, uid, c: uid, } - def _check_nonzero_planline(self, cr, uid, ids, context=None): - """checks that there is at least one planline set""" - for plan in self.browse(cr, uid, ids, context): - if len(plan.planline_ids) < 1: - return False - return True - - 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 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 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""" context = context or {} @@ -208,7 +189,7 @@ class gamification_goal_plan(osv.Model): """Daily cron check. Start planned plans (in draft and with start_date = today) - Create the goals for planlines not linked to goals (eg: modified the + Create the goals for planlines not linked to goals (eg: modified the plan to add planlines) Update every goal running """ @@ -226,7 +207,6 @@ class gamification_goal_plan(osv.Model): goal_obj = self.pool.get('gamification.goal') # we use yesterday to update the goals that just ended yesterday = date.today() - timedelta(days=1) - # TOCHECK conflict with date rule in goal update() function goal_ids = goal_obj.search(cr, uid, [ '&', ('state', 'not in', ('draft', 'canceled')), @@ -246,9 +226,12 @@ class gamification_goal_plan(osv.Model): if not context: context = {} goal_obj = self.pool.get('gamification.goal') - self.generate_goals_from_plan(cr, uid, ids, context=context) - for plan in self.browse(cr, uid, ids, context=context): + if plan.autojoin_group_id: + print("subscribe from group", plan.autojoin_group_id, [user.id for user in plan.autojoin_group_id.users]) + self.plan_subscribe_users(cr, uid, ids, [user.id for user in plan.autojoin_group_id.users], context=context) + self.generate_goals_from_plan(cr, uid, [plan.id], context=context) + # goals closed but still opened at the last report date closed_goals_to_report = goal_obj.search(cr, uid, [ ('plan_id', '=', plan.id), @@ -568,7 +551,7 @@ class gamification_goal_planline(osv.Model): _name = 'gamification.goal.planline' _description = 'Gamification generic goal for plan' - _order = "sequence_type" + _order = "sequence_type, id" def _get_planline_types(self, cr, uid, ids, context=None): """Return the ids of planline items related to the gamification.goal.type @@ -583,8 +566,10 @@ class gamification_goal_planline(osv.Model): return result.keys() _columns = { + 'name': fields.related('type_id', 'name', string="Name"), 'plan_id': fields.many2one('gamification.goal.plan', string='Plan', + required=True, ondelete="cascade"), 'type_id': fields.many2one('gamification.goal.type', string='Goal Type', diff --git a/addons/gamification/plan_view.xml b/addons/gamification/plan_view.xml index 44a9178d979..2c5828368ee 100644 --- a/addons/gamification/plan_view.xml +++ b/addons/gamification/plan_view.xml @@ -77,7 +77,8 @@