diff options
| author | Pratima Gupta <pgu@odoo.com> | 2018-11-20 06:40:45 +0000 |
|---|---|---|
| committer | Vincent Schippefilt <vsc@odoo.com> | 2019-06-26 09:04:06 +0000 |
| commit | e719824271a6368ce8b3e5ff2a3f5d5a3399b23c (patch) | |
| tree | 7b663ad495638aef93db233b5cce9e7783bafeee /addons/web/static/tests/fields/relational_fields_mobile_tests.js | |
| parent | 83aaea9e5ce92530875e4fca606a89fe423803ef (diff) | |
[IMP] web: hide "Remove" button in FormViewDialog
When we open any x2m record (in a FormViewDialog), there is a "Remove"
button to delete/unlink the opened record from parent.
This button is placed besides "Discard" button and it creates little
confusion in some cases. For example, in list view, there's already a
bin / 'x' icon depending on the field type using which people are used
to delete/unlink the record. And when they open a record, they might
accidentally click "Remove" button instead of "Discard".
To avoid this, now we won't show "Remove" button when we open record from
x2many list view. However, we have to keep this button in case x2many of
kanban as there's no other way to remove the record.
task-1886913
closes odoo/odoo#34333
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Diffstat (limited to 'addons/web/static/tests/fields/relational_fields_mobile_tests.js')
| -rw-r--r-- | addons/web/static/tests/fields/relational_fields_mobile_tests.js | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/addons/web/static/tests/fields/relational_fields_mobile_tests.js b/addons/web/static/tests/fields/relational_fields_mobile_tests.js index 794a8a89545..640a9298368 100644 --- a/addons/web/static/tests/fields/relational_fields_mobile_tests.js +++ b/addons/web/static/tests/fields/relational_fields_mobile_tests.js @@ -20,6 +20,7 @@ QUnit.module('relational_fields', { qux: {string: "Qux", type: "float", digits: [16,1] }, p: {string: "one2many field", type: "one2many", relation: 'partner', relation_field: 'trululu'}, trululu: {string: "Trululu", type: "many2one", relation: 'partner'}, + partner_ids: {string: "many2many field", type: "many2many", relation: 'partner'}, }, records: [{ id: 1, @@ -114,6 +115,65 @@ QUnit.module('relational_fields', { await testUtils.form.clickSave(form); form.destroy(); }); + + QUnit.module('FieldMany2Many'); + + QUnit.test('many2many kanban: deletion in mobile', async function (assert) { + assert.expect(8); + this.data.partner.records[0].partner_ids = [2, 4]; + var form = await createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: '<form string="Partners">' + + '<field name="display_name"/>' + + '<field name="partner_ids">' + + '<kanban>' + + '<field name="display_name"/>' + + '<templates>' + + '<t t-name="kanban-box">' + + '<div class="oe_kanban_global_click">' + + '<span><t t-esc="record.display_name.value"/></span>' + + '</div>' + + '</t>' + + '</templates>' + + '</kanban>' + + '<form string="Partners">' + + '<field name="display_name"/>' + + '</form>' + + '</field>' + + '</form>', + res_id: 1, + mockRPC: function (route, args) { + if (route === '/web/dataset/call_kw/partner/write') { + var commands = args.args[1].partner_ids; + assert.strictEqual(commands.length, 1, + 'should have generated one commands'); + assert.deepEqual(commands[0], [6, false, [4]] , + 'should properly write ids'); + } + return this._super.apply(this, arguments); + }, + }); + assert.containsNone(form.$('.o_field_many2many .o-kanban-button-new'), + '"Add" button should not be visible in readonly'); + await testUtils.form.clickEdit(form); + assert.containsOnce(form, '.o_field_many2many .o-kanban-button-new', + '"Add" button should be visible in edit'); + assert.containsN(form, '.o_kanban_record:not(.o_kanban_ghost)', 2, + "should have 2 records"); + // open and delete record + await testUtils.dom.click(form.$('.oe_kanban_global_click').first()); + assert.strictEqual($('.modal .modal-footer .o_btn_remove').length, 1, + 'there should be a modal having "Remove" Button'); + await testUtils.dom.click($('.modal .modal-footer .o_btn_remove')); + assert.containsNone($('.o_modal'), "modal should have been closed"); + assert.containsOnce(form, '.o_kanban_record:not(.o_kanban_ghost)', + 'should contain 1 records'); + // save and check that the correct command has been generated + await testUtils.form.clickSave(form); + form.destroy(); + }); }); }); }); |
