-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] Migrate web_search_with_and from 8.0 to 10.0
- Loading branch information
1 parent
a408946
commit 0e6f4bf
Showing
5 changed files
with
51 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
web_search_with_and/__openerp__.py → web_search_with_and/__manifest__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<openerp> | ||
<data> | ||
<template id="assets_backend" name="web_view_editor assets" inherit_id="web.assets_backend"> | ||
<xpath expr="." position="inside"> | ||
<script type="text/javascript" src="/web_search_with_and/static/src/js/search.js"/> | ||
</xpath> | ||
</template> | ||
</data> | ||
</openerp> | ||
<odoo> | ||
<template id="assets_backend" name="web_view_editor assets" inherit_id="web.assets_backend"> | ||
<xpath expr="." position="inside"> | ||
<script type="text/javascript" src="/web_search_with_and/static/src/js/search.js"/> | ||
</xpath> | ||
</template> | ||
</odoo> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,53 @@ | ||
openerp.web_search_with_and = function (instance) { | ||
odoo.define('web_search_with_and', function (require) { | ||
"use strict"; | ||
|
||
instance.web.SearchView = instance.web.SearchView.extend({ | ||
var SearchView = require('web.SearchView'); | ||
var Backbone = window.Backbone; | ||
|
||
SearchView.include({ | ||
// Override the base method to detect a 'shift' event | ||
select_completion: function (e, ui) { | ||
var self = this; | ||
if (e.shiftKey) { | ||
if (e.shiftKey | ||
&& ui.item.facet.values | ||
&& ui.item.facet.values.length | ||
&& String(ui.item.facet.values[0].value).trim() !== "") { | ||
// In case of an 'AND' search a new facet is added regarding of the previous facets | ||
e.preventDefault(); | ||
|
||
var input_index = _(this.input_subviews).indexOf( | ||
this.subviewForRoot( | ||
this.$('div.oe_searchview_input:focus')[0])); | ||
this.query.add(ui.item.facet, {at: input_index / 2, shiftKey: true}); | ||
this.query.add(ui.item.facet, {shiftKey: true}); | ||
} else { | ||
this._super(e, ui); | ||
|
||
return this._super.apply(this, arguments); | ||
} | ||
}, | ||
} | ||
}); | ||
|
||
instance.web.search.SearchQuery = instance.web.search.SearchQuery.extend({ | ||
SearchView.SearchQuery.prototype = SearchView.SearchQuery.extend({ | ||
// Override the odoo method to (conditionally) add a search facet even if a existing | ||
// facet for the same field/category already exists | ||
add: function (values, options) { | ||
|
||
options = options || {}; | ||
if (options.shiftKey) { | ||
|
||
if (!values) { | ||
values = []; | ||
} else if (!(values instanceof Array)) { | ||
values = [values]; | ||
} | ||
if (!values) { | ||
values = []; | ||
} | ||
else if (!(values instanceof Array)) { | ||
values = [values]; | ||
} | ||
|
||
if (options.shiftKey) { | ||
delete options.shiftKey; | ||
_(values).each(function (value) { | ||
var model = this._prepareModel(value, options); | ||
Backbone.Collection.prototype.add.call(this, model, options); | ||
}, this); | ||
|
||
return this; | ||
} | ||
else { | ||
return this.constructor.__super__.add.apply(this, arguments); | ||
return this.constructor.__super__.add.call(this, values, options); | ||
} | ||
}, | ||
}); | ||
}; | ||
} | ||
}).prototype; | ||
|
||
}); |