From ac5a1662f2ff1cc2287c1453920c80e78c617c0b Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Wed, 21 Nov 2018 16:37:40 +0000 Subject: [FIX] web: propagate can_create into the search popup When creating a SO line and clicking on search more for product_id Before this commit, every user had the button "Create" to create a product.product After this commit, only user in groups that actually can create a product have the button OPW 1910371 closes odoo/odoo#28924 --- .../web/static/tests/views/view_dialogs_tests.js | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'addons/web/static/tests/views/view_dialogs_tests.js') diff --git a/addons/web/static/tests/views/view_dialogs_tests.js b/addons/web/static/tests/views/view_dialogs_tests.js index b18c552830f..f6b2b7cd441 100644 --- a/addons/web/static/tests/views/view_dialogs_tests.js +++ b/addons/web/static/tests/views/view_dialogs_tests.js @@ -420,6 +420,65 @@ QUnit.module('Views', { form.destroy(); }); + QUnit.test('propagate can_create onto the search popup o2m', function (assert) { + assert.expect(3); + + this.data.instrument.records = [ + {id: 1, name: 'Tromblon1'}, + {id: 2, name: 'Tromblon2'}, + {id: 3, name: 'Tromblon3'}, + {id: 4, name: 'Tromblon4'}, + {id: 5, name: 'Tromblon5'}, + {id: 6, name: 'Tromblon6'}, + {id: 7, name: 'Tromblon7'}, + {id: 8, name: 'Tromblon8'}, + ]; + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: '
' + + '' + + '' + + '', + res_id: 1, + archs: { + 'instrument,false,list': ''+ + ''+ + '', + 'instrument,false,search': ''+ + ''+ + '', + }, + viewOptions: { + mode: 'edit', + }, + + mockRPC: function(route, args) { + if (args.method === 'get_formview_id') { + return $.when(false); + } + return this._super(route, args); + }, + }); + + form.$('.o_field_widget[name="instrument"] .o_input').click(); + + assert.notOk($('.ui-autocomplete a:contains(Create and Edit)').length, + 'Create and edit not present in dropdown'); + + $('.ui-autocomplete a:contains(Search More)').trigger('mouseenter').trigger('click'); + + var $modal = $('.modal-dialog.modal-lg'); + + assert.strictEqual($modal.length, 1, 'Modal present'); + + assert.strictEqual($modal.find('.modal-footer button').text(), "Cancel", + 'Only the cancel button is present in modal'); + + form.destroy(); + }); }); }); -- cgit v1.2.3