diff --git a/addons/gamification/models/challenge.py b/addons/gamification/models/challenge.py index 2a1c6d5b0a5b10b939c64fc4fbdbb75cd99570b5..4e128fc8f12bece3da1bfc4c9a59756addc0cd51 100644 --- a/addons/gamification/models/challenge.py +++ b/addons/gamification/models/challenge.py @@ -204,6 +204,7 @@ class gamification_challenge(osv.Model): 'category': 'hr', 'reward_failure': False, 'report_template_id': lambda s, *a, **k: s._get_report_template(*a, **k), + 'reward_realtime': True, } @@ -361,6 +362,9 @@ class gamification_challenge(osv.Model): return True + def action_start(self, cr, uid, ids, context=None): + """Start a challenge""" + return self.write(cr, uid, ids, {'state': 'inprogress'}, context=context) def action_check(self, cr, uid, ids, context=None): """Check a challenge @@ -707,7 +711,7 @@ class gamification_challenge(osv.Model): rewarded_users = [] challenge_ended = end_date == yesterday.strftime(DF) or force - if challenge.reward_id and challenge_ended or challenge.reward_realtime: + if challenge.reward_id and (challenge_ended or challenge.reward_realtime): # not using start_date as intemportal goals have a start date but no end_date reached_goals = self.pool.get('gamification.goal').read_group(cr, uid, [ ('challenge_id', '=', challenge.id), diff --git a/addons/gamification/static/src/js/gamification.js b/addons/gamification/static/src/js/gamification.js index 6e2e52019689110ad1f8fecedc58442bc722c567..0c02162e59fbed07f921d9d109958e277405dc45 100644 --- a/addons/gamification/static/src/js/gamification.js +++ b/addons/gamification/static/src/js/gamification.js @@ -125,16 +125,5 @@ openerp.gamification = function(instance) { sidebar.appendTo($('.oe_mail_wall_aside')); }, }); - - instance.web_kanban.KanbanRecord.include({ - // open related goals when clicking on challenge kanban view - on_card_clicked: function() { - if (this.view.dataset.model === 'gamification.challenge') { - this.$('.oe_kanban_project_list a').first().click(); - } else { - this._super.apply(this, arguments); - } - }, - }); }; diff --git a/addons/gamification/views/badge.xml b/addons/gamification/views/badge.xml index 302ad66caf02f4763707c7bd5db91b6c21ef978d..315ccd683084ec03d9f3f7da922009a8d49d43b4 100644 --- a/addons/gamification/views/badge.xml +++ b/addons/gamification/views/badge.xml @@ -75,7 +75,7 @@ </div> </group> <group string="Rewards for challenges"> - <field name="challenge_ids" widget="many2many_kanban" nolabel="1" /> + <field name="challenge_ids" widget="many2many_kanban" nolabel="1" context="{'default_reward_id': active_id}" /> </group> <group string="Statistics"> <group> diff --git a/addons/gamification/views/challenge.xml b/addons/gamification/views/challenge.xml index 9c76b73bdae43e52dd4bf0d76cc25bd9a6a60b58..75515c421831b315ae31e02361c7d093f68e30b6 100644 --- a/addons/gamification/views/challenge.xml +++ b/addons/gamification/views/challenge.xml @@ -34,6 +34,7 @@ <field name="arch" type="xml"> <form string="Goal definitions"> <header> + <button string="Start Challenge" type="object" name="action_start" states="draft" class="oe_highlight"/> <button string="Refresh Challenge" type="object" name="action_check" states="inprogress"/> <button string="Send Report" type="object" name="action_report_progress" states="inprogress,done" groups="base.group_no_one"/> <field name="state" widget="statusbar" clickable="True"/> @@ -48,7 +49,7 @@ <label for="user_domain" class="oe_edit_only" string="Assign Challenge To"/> <div> <field name="user_domain" widget="char_domain" options="{'model': 'res.users'}" /> - <field name="user_ids" groups="base.group_no_one" widget="many2many_tags" /> + <field name="user_ids" groups="base.group_no_one" widget="many2many_tags" readonly="True" /> </div> </div> @@ -142,12 +143,6 @@ <templates> <t t-name="kanban-box"> <div t-attf-class="oe_kanban_card oe_kanban_goal oe_kanban_global_click"> - <div class="oe_dropdown_toggle oe_dropdown_kanban"> - <span class="oe_e">Ã</span> - <ul class="oe_dropdown_menu"> - <li><a type="edit">Configure Challenge</a></li> - </ul> - </div> <div class="oe_kanban_content"> <strong> <h4 class="text-center"><field name="name"/></h4> diff --git a/addons/gamification/views/goal.xml b/addons/gamification/views/goal.xml index ed0702f9a52509de1960ac4c0088826eef5ca4ff..e8081f4bc21c292e6b5fd1871c7fa9259361db3e 100644 --- a/addons/gamification/views/goal.xml +++ b/addons/gamification/views/goal.xml @@ -98,13 +98,21 @@ <filter name="my" string="My Goals" domain="[('user_id', '=', uid)]"/> <separator/> <filter name="draft" string="Draft" domain="[('state', '=', 'draft')]"/> - <filter name="inprogress" string="Current" + <filter name="inprogress" string="Running" domain="[ '|', ('state', '=', 'inprogress'), - ('end_date', '>=', context_today().strftime('%%Y-%%m-%%d')) - ]"/> - <filter name="closed" string="Passed" domain="[('state', 'in', ('reached', 'failed'))]"/> + '&', + ('state', 'in', ('done', 'failed')), + ('end_date', '>=', context_today().strftime('%%Y-%%m-%%d')) + ]"/> + <filter name="closed" string="Done" + domain="[ + ('state', 'in', ('reached', 'failed')), + '|', + ('end_date', '=', False), + ('end_date', '<', context_today().strftime('%%Y-%%m-%%d')) + ]"/> <separator/> <field name="user_id"/> diff --git a/addons/hr_gamification/views/gamification.xml b/addons/hr_gamification/views/gamification.xml index 60c758a717d6a9e4a357fb40446d05318d0fc35e..1c95fef53d5182eaaa5820b5c165d1cf7ba456e2 100644 --- a/addons/hr_gamification/views/gamification.xml +++ b/addons/hr_gamification/views/gamification.xml @@ -21,7 +21,7 @@ <field name="inherit_id" ref="hr.view_employee_form"/> <field name="arch" type="xml"> - <xpath expr="//page[@string='Public Information']" position="before"> + <xpath expr="//page[@string='Public Information']" position="after"> <page string="Received Badges" attrs="{'invisible': [('user_id', '=', False)]}"> <field name="has_badges" invisible="1"/> <button string="Grant a Badge" type="action" name="%(action_reward_wizard)d"/> to reward this employee for a good action @@ -34,8 +34,6 @@ </div> <field name="badge_ids" widget="many2many_kanban" /> </page> - </xpath> - <xpath expr="//page[@string='Public Information']" position="after"> <page string="Goals"> <field name="goal_ids" widget="many2many_kanban" /> </page>