[FIX] web: handle correctly deactivation of duplicate option

This new behavior has been introduced by previous forward-port.
This commit is contained in:
Christophe Simonis
2017-06-12 20:10:11 +02:00
parent 50d8ea1d58
commit 76262f2043
2 changed files with 28 additions and 0 deletions
@@ -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,
};
@@ -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: '<form string="Partners" duplicate="false">' +
'<field name="foo"/>' +
'</form>',
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);