[FIX] web, *: fix domain building without CompoundDomain

* board, google_spreadsheet

Commit 8e0c7ccc77f358601b0701536fcb33842ca324a6 got rid of the
CompoundDomain class but did not adapt the code correctly.

- Domains have to be concatened, not regrouped in a big array
- String domains have to be converted to array
- "OR" joining must normalize subdomains first (add explicit "AND"s)
This commit is contained in:
qsm-odoo
2017-04-11 19:44:38 +02:00
committed by Aaron Bohy
parent f738edb1d6
commit e1b68dae50
4 changed files with 10 additions and 3 deletions
+1 -1
View File
@@ -404,7 +404,7 @@ FavoriteMenu.include({
domain = this.searchview.dataset.get_domain() || [];
_.each(search_data.contexts, context.add, context);
_.each(search_data.domains, function (d) {
domain.push(Domain.prototype.stringToArray(d));
domain.push.apply(domain, Domain.prototype.stringToArray(d));
});
context.add({
@@ -33,7 +33,7 @@ FavoriteMenu.include({
ds = new data.DataSet(this, 'google.drive.config');
_.each(sv_data.domains, function (d) {
domain.push(Domain.prototype.stringToArray(d));
domain.push.apply(domain, Domain.prototype.stringToArray(d));
});
ds.call('set_spreadsheet', [model, Domain.prototype.arrayToString(domain), groupbys, list_view_id])
.done(function (res) {
@@ -170,6 +170,7 @@ var Field = Input.extend( /** @lends instance.web.search.Field# */ {
return domains[0];
}
_.each(domains, Domain.prototype.normalizeArray);
var ors = _.times(domains.length - 1, _.constant("|"));
return ors.concat.apply(ors, domains);
}
@@ -619,10 +620,14 @@ var FilterGroup = Input.extend(/** @lends instance.web.search.FilterGroup# */{
* @return {*} combined domains of the enabled filters in this group
*/
get_domain: function (facet) {
var userContext = this.getSession().user_context;
var domains = facet.values.chain()
.map(function (f) { return f.get('value').attrs.domain; })
.without('[]')
.reject(_.isEmpty)
.map(function (d) {
return Domain.prototype.stringToArray(d, userContext);
})
.value();
if (!domains.length) {
@@ -632,6 +637,7 @@ var FilterGroup = Input.extend(/** @lends instance.web.search.FilterGroup# */{
return domains[0];
}
_.each(domains, Domain.prototype.normalizeArray);
var ors = _.times(domains.length - 1, _.constant("|"));
return ors.concat.apply(ors, domains);
},
@@ -129,7 +129,6 @@ QUnit.module('chrome', {}, function () {
assert.strictEqual(query.length, 0, 'Should have removed the facet');
});
QUnit.test('Intermediate emptiness should not remove the facet', function (assert) {
assert.expect(3);
@@ -167,5 +166,7 @@ QUnit.module('chrome', {}, function () {
]);
});
// TODO add a test to check that combining two filters with a or normalizes the two filters before
// Note: maybe domain.js will be improved to make this easier
});
});