Andrea
6 years ago
19 changed files with 155 additions and 188 deletions
-
10date_range/README.rst
-
1date_range/__init__.py
-
9date_range/__manifest__.py
-
9date_range/migrations/11.0.2.0.0/noupdate_changes.xml
-
3date_range/migrations/11.0.2.0.0/openupgrade_analysis.txt
-
4date_range/migrations/11.0.2.0.0/openupgrade_analysis_work.txt
-
11date_range/migrations/11.0.2.0.0/post-migration.py
-
1date_range/models/__init__.py
-
14date_range/models/date_range.py
-
14date_range/models/date_range_type.py
-
1date_range/readme/CONTRIBUTORS.rst
-
2date_range/readme/INSTALL.rst
-
210date_range/static/src/js/date_range.js
-
1date_range/tests/__init__.py
-
10date_range/tests/test_date_range.py
-
13date_range/tests/test_date_range_generator.py
-
7date_range/tests/test_date_range_type.py
-
1date_range/wizard/__init__.py
-
22date_range/wizard/date_range_generator.py
@ -1,4 +1,3 @@ |
|||
# © 2016 ACSONE SA/NV (<http://acsone.eu>) |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
|
|||
from . import models |
|||
|
@ -1,9 +0,0 @@ |
|||
<?xml version='1.0' encoding='utf-8'?> |
|||
<odoo> |
|||
<record id="date_range_type_comp_rule" model="ir.rule"> |
|||
<field name="domain_force"> ['|',('company_id','child_of',[user.company_id.id]),('company_id','=',False)]</field> |
|||
</record> |
|||
<record id="date_range_comp_rule" model="ir.rule"> |
|||
<field name="domain_force"> ['|',('company_id','child_of',[user.company_id.id]),('company_id','=',False)]</field> |
|||
</record> |
|||
</odoo> |
@ -1,3 +0,0 @@ |
|||
---Fields in module 'date_range'--- |
|||
---XML records in module 'date_range'--- |
|||
NEW ir.rule: date_range.date_range_generator_comp_rule (noupdate) |
@ -1,4 +0,0 @@ |
|||
---Fields in module 'date_range'--- |
|||
---XML records in module 'date_range'--- |
|||
NEW ir.rule: date_range.date_range_generator_comp_rule (noupdate) |
|||
# NOTHING TO DO |
@ -1,11 +0,0 @@ |
|||
# Copyright 2017 Eficent <http://www.eficent.com> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
from openupgradelib import openupgrade |
|||
|
|||
|
|||
@openupgrade.migrate() |
|||
def migrate(env, version): |
|||
openupgrade.load_data( |
|||
env.cr, 'date_range', 'migrations/11.0.2.0.0/noupdate_changes.xml', |
|||
) |
@ -1,4 +1,3 @@ |
|||
# © 2016 ACSONE SA/NV (<http://acsone.eu>) |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
|
|||
from . import date_range_type |
|||
|
@ -1,3 +1,4 @@ |
|||
* Laurent Mignon <laurent.mignon@acsone.eu> |
|||
* Alexis de Lattre <alexis.delattre@akretion.com> |
|||
* Miquel Raïch <miquel.raich@eficent.com> |
|||
* Andrea Stirpe <a.stirpe@onestein.nl> |
@ -1,3 +1 @@ |
|||
The addon use the daterange method from postgres. This method is supported as of postgresql 9.2 |
|||
|
|||
|
@ -1,125 +1,125 @@ |
|||
/* © 2016 ACSONE SA/NV (<http://acsone.eu>) |
|||
/* Copyright 2016 ACSONE SA/NV (<http://acsone.eu>) |
|||
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
|
|||
odoo.define('date_range.search_filters', function (require) { |
|||
"use strict"; |
|||
|
|||
var core = require('web.core'); |
|||
var data = require('web.data'); |
|||
var filters = require('web.search_filters'); |
|||
var rpc = require('web.rpc'); |
|||
var framework = require('web.framework'); |
|||
|
|||
var _t = core._t; |
|||
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.$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]]); |
|||
ds.read_slice(['name'], {}).done(this.proxy('add_date_range_types_operator')); |
|||
} |
|||
}, |
|||
|
|||
add_date_range_types_operator: function(date_range_types){ |
|||
var self = this; |
|||
_.each(date_range_types, function(drt) { |
|||
$('<option>', {value: 'drt_' + drt.id}) |
|||
.text(_('in ') + drt.name) |
|||
.appendTo(self.$el.find('.searchview_extended_prop_op, .o_searchview_extended_prop_op')); |
|||
}); |
|||
}, |
|||
|
|||
operator_changed: function (e) { |
|||
var val = $(e.target).val(); |
|||
this.is_date_range_selected = val.startsWith('drt_'); |
|||
if (this.is_date_range_selected){ |
|||
var type_id = val.replace('drt_', ''); |
|||
this.date_range_type_operator_selected(type_id); |
|||
return; |
|||
} |
|||
this._super.apply(this, arguments); |
|||
}, |
|||
|
|||
date_range_type_operator_selected: function(type_id){ |
|||
this.$value.empty().show(); |
|||
var ds = new data.DataSetSearch(this, 'date.range', this.context, [['type_id', '=', parseInt(type_id)]]); |
|||
ds.read_slice(['name','date_start', 'date_end'], {}).done(this.proxy('on_range_type_selected')); |
|||
|
|||
}, |
|||
|
|||
on_range_type_selected: function(date_range_values){ |
|||
this.value = new filters.ExtendedSearchProposition.DateRange(this, this.value.field, date_range_values); |
|||
this.value.appendTo(this.$value); |
|||
if (!this.$el.hasClass('o_filter_condition')){ |
|||
this.$value.find('.date-range-select').addClass('form-control'); |
|||
} |
|||
this.value.on_range_selected(); |
|||
}, |
|||
|
|||
get_filter: function () { |
|||
var res = this._super.apply(this, arguments); |
|||
if (this.is_date_range_selected){ |
|||
// in case of date.range, the domain is provided by the server and we don't
|
|||
// want to put nest the returned value into an array.
|
|||
res.attrs.domain = this.value.domain; |
|||
"use strict"; |
|||
|
|||
var core = require('web.core'); |
|||
var data = require('web.data'); |
|||
var filters = require('web.search_filters'); |
|||
var rpc = require('web.rpc'); |
|||
var framework = require('web.framework'); |
|||
|
|||
var _t = core._t; |
|||
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.$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]]); |
|||
ds.read_slice(['name'], {}).done(this.proxy('add_date_range_types_operator')); |
|||
} |
|||
}, |
|||
|
|||
add_date_range_types_operator: function (date_range_types) { |
|||
var self = this; |
|||
_.each(date_range_types, function (drt) { |
|||
$('<option>', {value: 'drt_' + drt.id}) |
|||
.text(_('in ') + drt.name) |
|||
.appendTo(self.$el.find('.searchview_extended_prop_op, .o_searchview_extended_prop_op')); |
|||
}); |
|||
}, |
|||
|
|||
operator_changed: function (e) { |
|||
var val = $(e.target).val(); |
|||
this.is_date_range_selected = val.startsWith('drt_'); |
|||
if (this.is_date_range_selected) { |
|||
var type_id = val.replace('drt_', ''); |
|||
this.date_range_type_operator_selected(type_id); |
|||
return; |
|||
} |
|||
this._super.apply(this, arguments); |
|||
}, |
|||
|
|||
date_range_type_operator_selected: function (type_id) { |
|||
this.$value.empty().show(); |
|||
var ds = new data.DataSetSearch(this, 'date.range', this.context, [['type_id', '=', parseInt(type_id, 10)]]); |
|||
ds.read_slice(['name','date_start', 'date_end'], {}).done(this.proxy('on_range_type_selected')); |
|||
|
|||
}, |
|||
|
|||
on_range_type_selected: function (date_range_values) { |
|||
this.value = new filters.ExtendedSearchProposition.DateRange(this, this.value.field, date_range_values); |
|||
this.value.appendTo(this.$value); |
|||
if (!this.$el.hasClass('o_filter_condition')) { |
|||
this.$value.find('.date-range-select').addClass('form-control'); |
|||
} |
|||
this.value.on_range_selected(); |
|||
}, |
|||
|
|||
get_filter: function () { |
|||
var res = this._super.apply(this, arguments); |
|||
if (this.is_date_range_selected) { |
|||
// In case of date.range, the domain is provided by the server and we don't
|
|||
// Want to put nest the returned value into an array.
|
|||
res.attrs.domain = this.value.domain; |
|||
} |
|||
return res; |
|||
} |
|||
return res; |
|||
}, |
|||
|
|||
}); |
|||
}); |
|||
|
|||
/** |
|||
/** |
|||
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', |
|||
}, |
|||
|
|||
init: function (parent, field, date_range_values) { |
|||
this._super(parent, field); |
|||
this.date_range_values = date_range_values; |
|||
}, |
|||
|
|||
toString: function () { |
|||
var select = this.$el[0]; |
|||
var option = select.options[select.selectedIndex]; |
|||
return option.label || option.text; |
|||
}, |
|||
|
|||
get_value: function() { |
|||
return parseInt(this.$el.val()); |
|||
}, |
|||
|
|||
on_range_selected: function(e){ |
|||
var self = this; |
|||
self.domain = ''; |
|||
framework.blockUI(); |
|||
return rpc.query({ |
|||
filters.ExtendedSearchProposition.DateRange = core.search_filters_registry.get('id').extend({ |
|||
template: 'SearchView.extended_search.dateRange.selection', |
|||
events: { |
|||
'change': 'on_range_selected' |
|||
}, |
|||
|
|||
init: function (parent, field, date_range_values) { |
|||
this._super(parent, field); |
|||
this.date_range_values = date_range_values; |
|||
}, |
|||
|
|||
toString: function () { |
|||
var select = this.$el[0]; |
|||
var option = select.options[select.selectedIndex]; |
|||
return option.label || option.text; |
|||
}, |
|||
|
|||
get_value: function () { |
|||
return parseInt(this.$el.val(), 10); |
|||
}, |
|||
|
|||
on_range_selected: function (e) { |
|||
var self = this; |
|||
self.domain = ''; |
|||
framework.blockUI(); |
|||
return rpc.query({ |
|||
args: [this.get_value()], |
|||
kwargs: { |
|||
field_name: this.field.name |
|||
}, |
|||
model: 'date.range', |
|||
method: 'get_domain', |
|||
method: 'get_domain' |
|||
}) |
|||
.then(function (domain) { |
|||
framework.unblockUI(); |
|||
self.domain = domain; |
|||
}); |
|||
}, |
|||
|
|||
get_domain: function (field, operator) { |
|||
return this.domain; |
|||
}, |
|||
.then(function (domain) { |
|||
framework.unblockUI(); |
|||
self.domain = domain; |
|||
}); |
|||
}, |
|||
|
|||
get_domain: function (field, operator) { |
|||
return this.domain; |
|||
} |
|||
|
|||
}); |
|||
}); |
|||
|
|||
}); |
@ -1,4 +1,3 @@ |
|||
# © 2016 ACSONE SA/NV (<http://acsone.eu>) |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
|
|||
from . import date_range_generator |
Write
Preview
Loading…
Cancel
Save
Reference in new issue