diff --git a/addons/account/static/src/js/reconciliation/reconciliation_renderer.js b/addons/account/static/src/js/reconciliation/reconciliation_renderer.js index c082d92764b..bd8d8e52982 100644 --- a/addons/account/static/src/js/reconciliation/reconciliation_renderer.js +++ b/addons/account/static/src/js/reconciliation/reconciliation_renderer.js @@ -109,8 +109,15 @@ var StatementRenderer = Widget.extend(FieldManagerMixin, { 'number': state.valuenow, 'timePerTransaction': Math.round(dt/1000/state.valuemax) })); - $done.appendTo(this.$el.first()); - this.$('.o_automatic_reconciliation').hide(); + this.$el.children().hide(); + // display rainbowman after full reconciliation + this.trigger_up('show_effect', { + type: 'rainbow_man', + fadeout: 'no', + message: $done, + click_close: false, + }); + this.$el.css('min-height', '450px'); } if (state.notifications) { diff --git a/addons/account/static/src/less/account_reconciliation.less b/addons/account/static/src/less/account_reconciliation.less index 253dc25996f..4ecf02c8416 100644 --- a/addons/account/static/src/less/account_reconciliation.less +++ b/addons/account/static/src/less/account_reconciliation.less @@ -35,16 +35,6 @@ } } - .done_message { - padding: 70px 20% 10px 20%; - text-align: center; - position: relative; - .fa { - position: absolute; - right: 20%; - } - } - .notification_area { clear: both; } diff --git a/addons/account/static/src/xml/account_reconciliation.xml b/addons/account/static/src/xml/account_reconciliation.xml index ea3c111eccc..9f6ec95142a 100644 --- a/addons/account/static/src/xml/account_reconciliation.xml +++ b/addons/account/static/src/xml/account_reconciliation.xml @@ -46,9 +46,8 @@
- -

Congrats, you're all done !

-

It took you to reconcile transactions.
That's on average seconds per transaction.

+

Congrats, you're all done!

+

You reconciled transactions in .
That's on average seconds per transaction.

diff --git a/addons/crm/models/crm_lead.py b/addons/crm/models/crm_lead.py index 9043091164a..81934b3418e 100644 --- a/addons/crm/models/crm_lead.py +++ b/addons/crm/models/crm_lead.py @@ -354,7 +354,52 @@ class Lead(models.Model): for lead in self: stage_id = lead._stage_find(domain=[('probability', '=', 100.0), ('on_change', '=', True)]) lead.write({'stage_id': stage_id.id, 'probability': 100}) - return True + if lead.user_id and lead.team_id and lead.planned_revenue: + query = """ + SELECT + SUM(CASE WHEN user_id = %(user_id)s THEN 1 ELSE 0 END) as total_won, + MAX(CASE WHEN date_closed >= CURRENT_DATE - INTERVAL '30 days' AND user_id = %(user_id)s THEN planned_revenue ELSE 0 END) as max_user_30, + MAX(CASE WHEN date_closed >= CURRENT_DATE - INTERVAL '7 days' AND user_id = %(user_id)s THEN planned_revenue ELSE 0 END) as max_user_7, + MAX(CASE WHEN date_closed >= CURRENT_DATE - INTERVAL '30 days' AND team_id = %(team_id)s THEN planned_revenue ELSE 0 END) as max_team_30, + MAX(CASE WHEN date_closed >= CURRENT_DATE - INTERVAL '7 days' AND team_id = %(team_id)s THEN planned_revenue ELSE 0 END) as max_team_7 + FROM crm_lead + WHERE + type = 'opportunity' + AND + active = True + AND + probability = 100 + AND + DATE_TRUNC('year', date_closed) = DATE_TRUNC('year', CURRENT_DATE) + AND + (user_id = %(user_id)s OR team_id = %(team_id)s) + """ + lead.env.cr.execute(query, {'user_id': lead.user_id.id, + 'team_id': lead.team_id.id}) + query_result = self.env.cr.dictfetchone() + + message = False + if query_result['total_won'] == 1: + message = _('Go, go, go! Congrats for your first deal.') + elif query_result['max_team_30'] == lead.planned_revenue: + message = _('Boom! Team record for the past 30 days.') + elif query_result['max_team_7'] == lead.planned_revenue: + message = _('Yeah! Deal of the last 7 days for the team.') + elif query_result['max_user_30'] == lead.planned_revenue: + message = _('You just beat your personal record for the past 30 days.') + elif query_result['max_user_7'] == lead.planned_revenue: + message = _('You just beat your personal record for the past 7 days.') + + if message: + return { + 'effect': { + 'fadeout': 'slow', + 'message': message, + 'img_url': '/web/image/%s/%s/image' % (lead.team_id.user_id._name, lead.team_id.user_id.id) if lead.team_id.user_id.image else '/web/static/src/img/smile.svg', + 'type': 'rainbow', + } + } + return True @api.multi def action_schedule_meeting(self): diff --git a/addons/crm/views/crm_lead_views.xml b/addons/crm/views/crm_lead_views.xml index eff22f19721..34db5f24c72 100644 --- a/addons/crm/views/crm_lead_views.xml +++ b/addons/crm/views/crm_lead_views.xml @@ -409,7 +409,7 @@
' + + '', + intercepts: { + execute_action: function (event) { + var effectDescription = pyeval.py_eval(event.data.action_data.effect); + assert.deepEqual(effectDescription, {message: 'Congrats!'}, "should have correct effect description"); + } + } + }); + + form.$('.o_form_statusbar .btn-default').click(); + form.destroy(); + }); + }); }); diff --git a/addons/web/static/tests/widgets/rainbow_man_tests.js b/addons/web/static/tests/widgets/rainbow_man_tests.js new file mode 100644 index 00000000000..e9674ebc3fe --- /dev/null +++ b/addons/web/static/tests/widgets/rainbow_man_tests.js @@ -0,0 +1,37 @@ +odoo.define('web.rainbow_man_tests', function (require) { +"use strict"; + +var RainbowMan = require('web.rainbow_man'); + +QUnit.module('widgets', {}, function () { + +QUnit.module('RainbowMan', { + beforeEach: function () { + this.data = { + message: 'Congrats!', + click_close: false + }; + }, +}, function () { + + QUnit.test("rendering a rainbowman", function (assert) { + assert.expect(2); + + var $target = $("#qunit-fixture"); + + // Create and display rainbowman + var rainbowman = new RainbowMan(this.data); + rainbowman.appendTo($target); + + var $rainbow = rainbowman.$(".o_reward_rainbow"); + assert.strictEqual($rainbow.length, 1, + "Should have displayed rainbow effect"); + + assert.ok(rainbowman.$('.o_reward_msg_content').html() === 'Congrats!', + "Card on the rainbowman should display 'Congrats!' message"); + + rainbowman.destroy(); + }); +}); +}); +}); diff --git a/addons/web/views/webclient_templates.xml b/addons/web/views/webclient_templates.xml index 71473f62f18..730b4d883e1 100644 --- a/addons/web/views/webclient_templates.xml +++ b/addons/web/views/webclient_templates.xml @@ -5,6 +5,7 @@ + @@ -23,6 +24,7 @@ + @@ -84,6 +86,7 @@ +