|
|
@ -6,16 +6,15 @@ odoo.define('date_range.search_filters', function (require) { |
|
|
|
var core = require('web.core'); |
|
|
|
var data = require('web.data'); |
|
|
|
var filters = require('web.search_filters'); |
|
|
|
var Model = require('web.Model'); |
|
|
|
var rpc = require('web.rpc'); |
|
|
|
var framework = require('web.framework'); |
|
|
|
|
|
|
|
var _t = core._t; |
|
|
|
var _lt = core._lt; |
|
|
|
filters.ExtendedSearchProposition.include({ |
|
|
|
select_field: function(field) { |
|
|
|
this._super.apply(this, arguments); |
|
|
|
this.is_date_range_selected = false; |
|
|
|
this.is_date = field.type == 'date' || field.type == 'datetime'; |
|
|
|
this.is_date = field.type === 'date' || field.type === 'datetime'; |
|
|
|
this.$value = this.$el.find('.searchview_extended_prop_value, .o_searchview_extended_prop_value'); |
|
|
|
if (this.is_date){ |
|
|
|
var ds = new data.DataSetSearch(this, 'date.range.type', this.context, [[1, '=', 1]]); |
|
|
@ -71,7 +70,14 @@ filters.ExtendedSearchProposition.include({ |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
filters.ExtendedSearchProposition.DateRange = filters.ExtendedSearchProposition.Field.extend({ |
|
|
|
/** |
|
|
|
Since Odoo 11, The Field class used as base class for all specialized filter |
|
|
|
widgets is no more exposed by 'web.search_filters'. To create our own class we |
|
|
|
extend the more simple class available into the search_filters_registry as base |
|
|
|
class |
|
|
|
*/ |
|
|
|
|
|
|
|
filters.ExtendedSearchProposition.DateRange = core.search_filters_registry.get('id').extend({ |
|
|
|
template: 'SearchView.extended_search.dateRange.selection', |
|
|
|
events: { |
|
|
|
'change': 'on_range_selected', |
|
|
@ -96,12 +102,14 @@ filters.ExtendedSearchProposition.DateRange = filters.ExtendedSearchProposition. |
|
|
|
var self = this; |
|
|
|
self.domain = ''; |
|
|
|
framework.blockUI(); |
|
|
|
new Model("date.range") |
|
|
|
.call("get_domain", [ |
|
|
|
[this.get_value()], |
|
|
|
this.field.name, |
|
|
|
{} |
|
|
|
]) |
|
|
|
return rpc.query({ |
|
|
|
args: [this.get_value()], |
|
|
|
kwargs: { |
|
|
|
field_name: this.field.name |
|
|
|
}, |
|
|
|
model: 'date.range', |
|
|
|
method: 'get_domain', |
|
|
|
}) |
|
|
|
.then(function (domain) { |
|
|
|
framework.unblockUI(); |
|
|
|
self.domain = domain; |
|
|
|