[FIX] web,board: a kanban button action should trigger that action

Before this commit, when having a kanban within a dashboard and clicking on an action button,
the action was not triggered, instead, the board form view triggered 'save' on the board model
leading to a server side traceback

After this commit, the action button triggers the demanded one and only this one.

OPW 805707

closes #22191
closes #22371
This commit is contained in:
Lucas Perais (lpe)
2018-01-19 11:26:52 +01:00
parent 2c0793d981
commit 56052dee60
2 changed files with 53 additions and 0 deletions
@@ -417,5 +417,57 @@ QUnit.test('non-existing action in a dashboard', function (assert) {
form.destroy();
});
QUnit.test('clicking on a kanban\'s button should trigger the action', function (assert) {
assert.expect(2);
var form = createView({
View: FormView,
model: 'board',
data: this.data,
arch: '<form string="My Dashboard">' +
'<board style="2-1">' +
'<column>' +
'<action name="149" string="Partner" view_mode="kanban" id="action_0_1"></action>' +
'</column>' +
'</board>' +
'</form>',
archs: {
'partner,false,kanban':
'<kanban class="o_kanban_test"><templates><t t-name="kanban-box">' +
'<div>' +
'<field name="foo"/>' +
'</div>' +
'<div><button name="sitting_on_a_park_bench" type="object">Eying little girls with bad intent</button>' +
'</div>' +
'</t></templates></kanban>',
},
intercepts: {
execute_action: function (event) {
var data = event.data;
assert.strictEqual(data.env.model, 'partner', "should have correct model");
assert.strictEqual(data.action_data.name, 'sitting_on_a_park_bench',
"should call correct method");
}
},
mockRPC: function (route) {
if (route === '/board/static/src/img/layout_1-1-1.png') {
return $.when();
}
if (route === '/web/action/load') {
return $.when({res_model: 'partner', view_mode: 'kanban', views: [[false, 'kanban']]});
}
if (route === '/web/dataset/search_read') {
return $.when({records: [{foo: 'aqualung'}]});
}
return this._super.apply(this, arguments);
}
});
form.$('.o_kanban_test').find('button:first').click();
form.destroy();
});
});
@@ -229,6 +229,7 @@ var KanbanController = BasicController.extend({
* @param {OdooEvent} event
*/
_onButtonClicked: function (event) {
event.stopPropagation();
var self = this;
var attrs = event.data.attrs;
var record = event.data.record;