summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/fields/relational_fields_tests.js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/web/static/tests/fields/relational_fields_tests.js')
-rw-r--r--addons/web/static/tests/fields/relational_fields_tests.js50
1 files changed, 50 insertions, 0 deletions
diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js
index f93e7c35ace..1c0b3a6d33b 100644
--- a/addons/web/static/tests/fields/relational_fields_tests.js
+++ b/addons/web/static/tests/fields/relational_fields_tests.js
@@ -2422,6 +2422,56 @@ QUnit.module('relational_fields', {
form.destroy();
});
+ QUnit.test('widget many2many_checkboxes with 40+ values', async function (assert) {
+ // 40 is the default limit for x2many fields. However, the many2many_checkboxes is a
+ // special field that fetches its data through the fetchSpecialData mechanism, and it
+ // uses the name_search server-side limit of 100. This test comes with a fix for a bug
+ // that occurred when the user (un)selected a checkbox that wasn't in the 40 first checkboxes,
+ // because the piece of data corresponding to that checkbox hadn't been processed by the
+ // BasicModel, whereas the code handling the change assumed it had.
+ assert.expect(3);
+
+ const records = [];
+ for (let id = 1; id <= 90; id++) {
+ records.push({
+ id,
+ display_name: `type ${id}`,
+ color: id % 7,
+ });
+ }
+ this.data.partner_type.records = records;
+ this.data.partner.records[0].timmy = records.map((r) => r.id);
+
+ const form = await createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch: '<form><field name="timmy" widget="many2many_checkboxes"/></form>',
+ res_id: 1,
+ async mockRPC(route, args) {
+ if (args.method === 'write') {
+ const expectedIds = records.map((r) => r.id);
+ expectedIds.pop();
+ assert.deepEqual(args.args[1].timmy, [[6, false, expectedIds]]);
+ }
+ return this._super(...arguments);
+ },
+ viewOptions: {
+ mode: 'edit',
+ },
+ });
+
+ assert.containsN(form, '.o_field_widget[name=timmy] input[type=checkbox]:checked', 90);
+
+ // toggle the last value
+ await testUtils.dom.click(form.$('.o_field_widget[name=timmy] input[type=checkbox]:last'));
+ assert.notOk(form.$('.o_field_widget[name=timmy] input[type=checkbox]:last').is(':checked'));
+
+ await testUtils.form.clickSave(form);
+
+ form.destroy();
+ });
+
QUnit.module('FieldMany2ManyBinaryMultiFiles');
QUnit.test('widget many2many_binary', async function (assert) {