Browse Source

[MIG] date_range: Adapt JS to new framework

pull/25/head
Laurent Mignon (ACSONE) 7 years ago
committed by Pedro M. Baeza
parent
commit
9616d5920f
  1. 4
      date_range/README.rst
  2. 1
      date_range/__init__.py
  3. 5
      date_range/__manifest__.py
  4. 1
      date_range/models/__init__.py
  5. 1
      date_range/models/date_range.py
  6. 1
      date_range/models/date_range_type.py
  7. 28
      date_range/static/src/js/date_range.js
  8. 1
      date_range/tests/__init__.py
  9. 1
      date_range/tests/test_date_range.py
  10. 1
      date_range/tests/test_date_range_generator.py
  11. 1
      date_range/tests/test_date_range_type.py
  12. 1
      date_range/wizard/__init__.py
  13. 1
      date_range/wizard/date_range_generator.py
  14. 2
      date_range/wizard/date_range_generator.xml

4
date_range/README.rst

@ -63,7 +63,7 @@ To configure this module, you need to:
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot :alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/149/11.0
:target: https://runbot.odoo-community.org/runbot/250/11.0
Known issues / Roadmap Known issues / Roadmap
@ -75,7 +75,7 @@ Bug Tracker
=========== ===========
Bugs are tracked on `GitHub Issues Bugs are tracked on `GitHub Issues
<https://github.com/OCA/server-tools/issues>`_. In case of trouble, please
<https://github.com/OCA/server-ux/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first, check there if your issue has already been reported. If you spotted it first,
help us smashing it by providing a detailed and welcomed feedback. help us smashing it by providing a detailed and welcomed feedback.

1
date_range/__init__.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# © 2016 ACSONE SA/NV (<http://acsone.eu>) # © 2016 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

5
date_range/__manifest__.py

@ -1,12 +1,11 @@
# -*- coding: utf-8 -*-
# © 2016 ACSONE SA/NV (<http://acsone.eu>) # © 2016 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{ {
"name": "Date Range", "name": "Date Range",
"summary": "Manage all kind of date range", "summary": "Manage all kind of date range",
"version": "11.0.1.0.0",
"version": "11.0.1.0.1",
"category": "Uncategorized", "category": "Uncategorized",
"website": "https://odoo-community.org/",
"website": "https://github.com/oca/server-ux",
"author": "ACSONE SA/NV, Odoo Community Association (OCA)", "author": "ACSONE SA/NV, Odoo Community Association (OCA)",
"license": "AGPL-3", "license": "AGPL-3",
"application": False, "application": False,

1
date_range/models/__init__.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# © 2016 ACSONE SA/NV (<http://acsone.eu>) # © 2016 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

1
date_range/models/date_range.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# © 2016 ACSONE SA/NV (<http://acsone.eu>) # © 2016 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

1
date_range/models/date_range_type.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# © 2016 ACSONE SA/NV (<http://acsone.eu>) # © 2016 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

28
date_range/static/src/js/date_range.js

@ -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,12 +102,14 @@ 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,
{}
])
return rpc.query({
args: [this.get_value()],
kwargs: {
field_name: this.field.name
},
model: 'date.range',
method: 'get_domain',
})
.then(function (domain) { .then(function (domain) {
framework.unblockUI(); framework.unblockUI();
self.domain = domain; self.domain = domain;

1
date_range/tests/__init__.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# © 2016 ACSONE SA/NV (<http://acsone.eu>) # © 2016 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

1
date_range/tests/test_date_range.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# © 2016 ACSONE SA/NV (<http://acsone.eu>) # © 2016 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

1
date_range/tests/test_date_range_generator.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# © 2016 ACSONE SA/NV (<http://acsone.eu>) # © 2016 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)nses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)nses/agpl).

1
date_range/tests/test_date_range_type.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# © 2016 ACSONE SA/NV (<http://acsone.eu>) # © 2016 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

1
date_range/wizard/__init__.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# © 2016 ACSONE SA/NV (<http://acsone.eu>) # © 2016 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

1
date_range/wizard/date_range_generator.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# © 2016 ACSONE SA/NV (<http://acsone.eu>) # © 2016 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

2
date_range/wizard/date_range_generator.xml

@ -4,7 +4,7 @@
<field name="name">date.range.generator.form</field> <field name="name">date.range.generator.form</field>
<field name="model">date.range.generator</field> <field name="model">date.range.generator</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<form string="Genrate Date Ranges">
<form string="Generate Date Ranges">
<group col="4"> <group col="4">
<field name="name_prefix"/> <field name="name_prefix"/>
<field name="type_id"/> <field name="type_id"/>

Loading…
Cancel
Save