|
@ -6,16 +6,15 @@ odoo.define('date_range.search_filters', function (require) { |
|
|
var core = require('web.core'); |
|
|
var core = require('web.core'); |
|
|
var data = require('web.data'); |
|
|
var data = require('web.data'); |
|
|
var filters = require('web.search_filters'); |
|
|
var filters = require('web.search_filters'); |
|
|
var Model = require('web.Model'); |
|
|
|
|
|
|
|
|
var rpc = require('web.rpc'); |
|
|
var framework = require('web.framework'); |
|
|
var framework = require('web.framework'); |
|
|
|
|
|
|
|
|
var _t = core._t; |
|
|
var _t = core._t; |
|
|
var _lt = core._lt; |
|
|
|
|
|
filters.ExtendedSearchProposition.include({ |
|
|
filters.ExtendedSearchProposition.include({ |
|
|
select_field: function(field) { |
|
|
select_field: function(field) { |
|
|
this._super.apply(this, arguments); |
|
|
this._super.apply(this, arguments); |
|
|
this.is_date_range_selected = false; |
|
|
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'); |
|
|
this.$value = this.$el.find('.searchview_extended_prop_value, .o_searchview_extended_prop_value'); |
|
|
if (this.is_date){ |
|
|
if (this.is_date){ |
|
|
var ds = new data.DataSetSearch(this, 'date.range.type', this.context, [[1, '=', 1]]); |
|
|
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', |
|
|
template: 'SearchView.extended_search.dateRange.selection', |
|
|
events: { |
|
|
events: { |
|
|
'change': 'on_range_selected', |
|
|
'change': 'on_range_selected', |
|
@ -96,16 +102,18 @@ filters.ExtendedSearchProposition.DateRange = filters.ExtendedSearchProposition. |
|
|
var self = this; |
|
|
var self = this; |
|
|
self.domain = ''; |
|
|
self.domain = ''; |
|
|
framework.blockUI(); |
|
|
framework.blockUI(); |
|
|
new Model("date.range") |
|
|
|
|
|
.call("get_domain", [ |
|
|
|
|
|
[this.get_value()], |
|
|
|
|
|
this.field.name, |
|
|
|
|
|
{} |
|
|
|
|
|
]) |
|
|
|
|
|
.then(function (domain) { |
|
|
|
|
|
framework.unblockUI(); |
|
|
|
|
|
self.domain = domain; |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
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; |
|
|
|
|
|
}); |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
get_domain: function (field, operator) { |
|
|
get_domain: function (field, operator) { |
|
|