From da152cfdbf003ea8eb7140486cf83c5ba60795ab Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Fri, 19 May 2017 15:12:23 +0200 Subject: [PATCH] [FIX] web: SelectCreateDialog: don't erase domain When a SelectCreateDialog was opened with a given domain, this domain was completely lost if the user wrote a new domain (or groupby) in the searchview, whereas they should be concatenated. --- .../web/static/src/js/views/view_dialogs.js | 6 +-- .../tests/fields/relational_fields_tests.js | 38 +++++++++++++++++++ 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/addons/web/static/src/js/views/view_dialogs.js b/addons/web/static/src/js/views/view_dialogs.js index 7e20cd74d04..956886910ce 100644 --- a/addons/web/static/src/js/views/view_dialogs.js +++ b/addons/web/static/src/js/views/view_dialogs.js @@ -375,11 +375,9 @@ var SelectCreateDialog = ViewDialog.extend({ }); }, _process_search_data: function (domains, contexts, groupbys) { - var user_context = this.getSession().user_context; - contexts = [user_context].concat(contexts); var results = pyeval.eval_domains_and_contexts({ - domains: domains || [], - contexts: contexts || [], + domains: [this.domain].concat(domains), + contexts: [this.context].concat(contexts), group_by_seq: groupbys || [] }); return { diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js index 8aa872dfb05..cb03e3a8952 100644 --- a/addons/web/static/tests/fields/relational_fields_tests.js +++ b/addons/web/static/tests/fields/relational_fields_tests.js @@ -3684,6 +3684,44 @@ QUnit.module('relational_fields', { form.destroy(); }); + QUnit.test('many2many with a domain', function (assert) { + // The domain specified on the field should not be replaced by the potential + // domain the user writes in the dialog, they should rather be concatenated + assert.expect(2); + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch:'
' + + '' + + '', + res_id: 1, + archs: { + 'partner_type,false,list': '' + + '' + + '', + 'partner_type,false,search': '' + + '' + + '', + }, + viewOptions: { + mode: 'edit', + }, + }); + + form.$('.o_field_x2many_list_row_add a').click(); + assert.strictEqual($('.modal .o_data_row').length, 1, + "should contain only one row (gold)"); + + $('.modal .o_searchview_input').trigger({type: 'keypress', which: 115}); // s + $('.modal .o_searchview_input').trigger({type: 'keydown', which: 13}); // enter + + assert.strictEqual($('.modal .o_data_row').length, 0, "should contain no row"); + + form.destroy(); + }); + QUnit.module('FieldStatus'); QUnit.test('static statusbar widget on many2one field', function (assert) {