diff --git a/addons/sale/static/src/js/sale.js b/addons/sale/static/src/js/sale.js index 1121a38501a..374508f721b 100644 --- a/addons/sale/static/src/js/sale.js +++ b/addons/sale/static/src/js/sale.js @@ -39,6 +39,8 @@ KanbanRecord.include({ .done(function() { self.trigger_up('kanban_record_update', {id: self.id}); }); + // TODO: previous lines can be refactored as follows (in master) + // self.trigger_up('kanban_record_update', {invoiced_target: value}); } }); }, diff --git a/addons/sale/static/tests/sales_team_dashboard_tests.js b/addons/sale/static/tests/sales_team_dashboard_tests.js new file mode 100644 index 00000000000..b1043dd64e1 --- /dev/null +++ b/addons/sale/static/tests/sales_team_dashboard_tests.js @@ -0,0 +1,70 @@ +odoo.define('sale.dashboard_tests', function (require) { +"use strict"; + +var KanbanView = require('web.KanbanView'); +var testUtils = require('web.test_utils'); + +var createView = testUtils.createView; + +QUnit.module('Sales Team Dashboard', { + beforeEach: function () { + this.data = { + 'crm.team': { + fields: { + foo: {string: "Foo", type: 'char'}, + invoiced_target: {string: "Invoiced_target", type: 'integer'}, + }, + records: [ + {id: 1, foo: "yop"}, + ], + }, + }; + } +}); + +QUnit.test('edit target with several o_kanban_primary_bottom divs', function (assert) { + assert.expect(4); + + var kanban = createView({ + View: KanbanView, + model: 'crm.team', + data: this.data, + arch: '' + + '' + + '' + + '
' + + '' + + 'Click to define a target' + + '
' + + '
' + + '
' + + '' + + '' + + '', + mockRPC: function (route, args) { + if (args.method === 'write') { + assert.strictEqual(args.args[1].invoiced_target, 123, + "new value is correctly saved"); + } + return this._super.apply(this, arguments); + }, + + }); + + assert.strictEqual(kanban.$('.o_kanban_view .sales_team_target_definition').length, 1, + "should have classname 'sales_team_target_definition'"); + assert.strictEqual(kanban.$('.o_kanban_primary_bottom').length, 2, + "should have two divs with classname 'o_kanban_primary_bottom'"); + + kanban.$('a.sales_team_target_definition').click(); + assert.strictEqual(kanban.$('.o_kanban_primary_bottom:last input').length, 1, + "should have rendered an input in the last o_kanban_primary_bottom div"); + + kanban.$('.o_kanban_primary_bottom:last input').focus(); + kanban.$('.o_kanban_primary_bottom:last input').val('123'); + kanban.$('.o_kanban_primary_bottom:last input').blur(); + + kanban.destroy(); +}); + +}); diff --git a/addons/sale/views/assets.xml b/addons/sale/views/assets.xml index 9f89db5ab72..c40cd1b43c7 100644 --- a/addons/sale/views/assets.xml +++ b/addons/sale/views/assets.xml @@ -11,4 +11,10 @@ + +