From 76262f2043db1afd6d67a386796107dce91100e4 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Mon, 12 Jun 2017 20:10:11 +0200 Subject: [PATCH] [FIX] web: handle correctly deactivation of duplicate option This new behavior has been introduced by previous forward-port. --- .../web/static/src/js/views/abstract_view.js | 1 + addons/web/static/tests/views/form_tests.js | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/addons/web/static/src/js/views/abstract_view.js b/addons/web/static/src/js/views/abstract_view.js index 1f91fc7a796..e14e064ee33 100644 --- a/addons/web/static/src/js/views/abstract_view.js +++ b/addons/web/static/src/js/views/abstract_view.js @@ -85,6 +85,7 @@ var AbstractView = Class.extend({ edit: viewInfo.arch.attrs.edit ? JSON.parse(viewInfo.arch.attrs.edit) : true, create: viewInfo.arch.attrs.create ? JSON.parse(viewInfo.arch.attrs.create) : true, delete: viewInfo.arch.attrs.delete ? JSON.parse(viewInfo.arch.attrs.delete) : true, + duplicate: viewInfo.arch.attrs.duplicate ? JSON.parse(viewInfo.arch.attrs.duplicate) : true, }, noContentHelp: params.action && params.action.help, }; diff --git a/addons/web/static/tests/views/form_tests.js b/addons/web/static/tests/views/form_tests.js index 21dd1ba32aa..23986635b88 100644 --- a/addons/web/static/tests/views/form_tests.js +++ b/addons/web/static/tests/views/form_tests.js @@ -1421,6 +1421,33 @@ QUnit.module('Views', { form.destroy(); }); + QUnit.test('cannot duplicate a record', function (assert) { + assert.expect(2); + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: '
' + + '' + + '', + res_id: 1, + viewOptions: {sidebar: true}, + mockRPC: function (route, args) { + if (args.method === 'search_read' && args.model === 'ir.attachment') { + return $.when([]); + } + return this._super.apply(this, arguments); + }, + }); + + assert.strictEqual(form.get('title'), 'first record', + "should have the display name of the record as title"); + assert.ok(form.sidebar.$('a:contains(Duplicate)').length === 0, + "should not contains a 'Duplicate' action"); + form.destroy(); + }); + QUnit.test('buttons in footer are moved to $buttons if necessary', function (assert) { // not sure about this test... assert.expect(2);