forked from Techsystech/web
[9.0][MIG] web_widget_datepicker_options: Upgrade to v9 (#546)
* [9.0][MIG] web_widget_datepicker: Upgrade to v9 * Change headers to shorter version and openerp tags to odoo tags * Update Readme * Improvement9.0
parent
1310c58f00
commit
85e1728697
|
@ -1,6 +1,8 @@
|
||||||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
|
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
|
||||||
:alt: License: AGPL-3
|
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
||||||
|
:alt: License: AGPL-3
|
||||||
|
|
||||||
|
=========================
|
||||||
Datepicker Widget Options
|
Datepicker Widget Options
|
||||||
=========================
|
=========================
|
||||||
|
|
||||||
|
@ -10,22 +12,25 @@ the datepicker widget. The option are passed as-is and are not validated.
|
||||||
To see all supported options, see the `API documentation
|
To see all supported options, see the `API documentation
|
||||||
<http://api.jqueryui.com/datepicker/>`_.
|
<http://api.jqueryui.com/datepicker/>`_.
|
||||||
|
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
=====
|
=====
|
||||||
|
|
||||||
You must pass all options through the "datepicker" field in the options::
|
You must pass all options through the "datepicker" field in the options::
|
||||||
|
|
||||||
...
|
...
|
||||||
<field name="date" options="{'datepicker':{'yearRange': 'c-100:c+0'}}"/>
|
<field name="date" options='{"datepicker":{"yearRange": "c-100:c+0"}}'/>
|
||||||
...
|
...
|
||||||
|
|
||||||
|
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
|
||||||
|
:alt: Try me on Runbot
|
||||||
|
:target: https://runbot.odoo-community.org/runbot/162/9.0
|
||||||
|
|
||||||
|
|
||||||
Known issues / Roadmap
|
Known issues / Roadmap
|
||||||
======================
|
======================
|
||||||
|
|
||||||
* Absolutely no validation on options.
|
* Absolutely no validation on options.
|
||||||
|
|
||||||
|
|
||||||
Bug Tracker
|
Bug Tracker
|
||||||
===========
|
===========
|
||||||
|
|
||||||
|
@ -34,10 +39,14 @@ In case of trouble, please 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
|
If you spotted it first, help us smashing it by providing a detailed and welcomed feedback
|
||||||
`here <https://github.com/OCA/web/issues/new?body=module:%20web_widget_datepicker_options%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
`here <https://github.com/OCA/web/issues/new?body=module:%20web_widget_datepicker_options%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||||
|
|
||||||
|
|
||||||
Credits
|
Credits
|
||||||
=======
|
=======
|
||||||
|
|
||||||
|
Images
|
||||||
|
------
|
||||||
|
|
||||||
|
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
|
||||||
|
|
||||||
Contributors
|
Contributors
|
||||||
------------
|
------------
|
||||||
|
|
||||||
|
|
|
@ -1,21 +1,3 @@
|
||||||
# -*- encoding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
##############################################################################
|
# Copyright 2015 Savoir-faire Linux
|
||||||
#
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
# OpenERP, Open Source Management Solution
|
|
||||||
# This module copyright (C) 2015 Savoir-faire Linux
|
|
||||||
# (<http://www.savoirfairelinux.com>).
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU Affero General Public License as
|
|
||||||
# published by the Free Software Foundation, either version 3 of the
|
|
||||||
# License, or (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU Affero General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
##############################################################################
|
|
||||||
|
|
|
@ -1,37 +1,20 @@
|
||||||
# -*- encoding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
##############################################################################
|
# Copyright 2015 Savoir-faire Linux
|
||||||
#
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
# OpenERP, Open Source Management Solution
|
|
||||||
# This module copyright (C) 2015 Savoir-faire Linux
|
|
||||||
# (<http://www.savoirfairelinux.com>).
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU Affero General Public License as
|
|
||||||
# published by the Free Software Foundation, either version 3 of the
|
|
||||||
# License, or (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU Affero General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
##############################################################################
|
|
||||||
|
|
||||||
{
|
{
|
||||||
"name": 'web_widget_datepicker_options',
|
"name": 'web_widget_datepicker_options',
|
||||||
"version": "8.0.1.0.0",
|
"version": "9.0.1.0.0",
|
||||||
"depends": [
|
"depends": [
|
||||||
'base',
|
'base',
|
||||||
'web',
|
'web',
|
||||||
],
|
],
|
||||||
"data": [
|
"data": [
|
||||||
'view/qweb.xml',
|
'view/qweb.xml',
|
||||||
|
'demo/web_widget_datepicker_options_demo.xml'
|
||||||
],
|
],
|
||||||
"author": "Vincent Vinet, "
|
"author": "Vincent Vinet, "
|
||||||
"Odoo Community Association (OCA)",
|
"Odoo Community Association (OCA)",
|
||||||
'installable': False,
|
"license": "AGPL-3",
|
||||||
"active": False,
|
'installable': True,
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<odoo>
|
||||||
|
<record id="datepicker_options" model="ir.ui.view">
|
||||||
|
<field name="name">datepicker_options</field>
|
||||||
|
<field name="model">res.users</field>
|
||||||
|
<field name="inherit_id" ref="base.view_users_form"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//page[@name='access_rights']" position="inside">
|
||||||
|
<h2>Datepicker Demo</h2>
|
||||||
|
<label for="date"/>
|
||||||
|
<field name="date" options='{"datepicker": {"calendarWeeks": false}}'/><br/>
|
||||||
|
<label for="create_date"/>
|
||||||
|
<field name="create_date" options="{'datepicker':{'calendarWeeks': false}}"/>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
|
@ -18,36 +18,43 @@
|
||||||
*/
|
*/
|
||||||
/*global openerp, _, $ */
|
/*global openerp, _, $ */
|
||||||
|
|
||||||
openerp.web_widget_datepicker_options = function (instance) {
|
odoo.define('web_widget_datepicker_options', function (require) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
instance.web.form.FieldDatetime.include({
|
var core = require('web.core');
|
||||||
initialize_content: function() {
|
|
||||||
this._super();
|
var DateTimeWidget = require('web.datepicker').DateTimeWidget;
|
||||||
|
var DateWidget = require('web.datepicker').DateWidget;
|
||||||
|
|
||||||
|
DateTimeWidget.include({
|
||||||
|
start: function(parent, options) {
|
||||||
|
this._super.apply(this, arguments);
|
||||||
var self = this;
|
var self = this;
|
||||||
if (this.datewidget) {
|
if (this.__parentedParent.options.datepicker) {
|
||||||
if (typeof this.options.datepicker === 'object') {
|
var options = this.__parentedParent.options.datepicker;
|
||||||
$.map(this.options.datepicker, function(value, key) {
|
$.each(options, function(value, key) {
|
||||||
self.datewidget.picker('option', key, value);
|
self.options[value] = key;
|
||||||
});
|
self.picker[value] = key;
|
||||||
}
|
self.picker.options[value] = key;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
instance.web.form.FieldDate.include({
|
DateWidget.include({
|
||||||
initialize_content: function() {
|
start: function(parent, options) {
|
||||||
this._super();
|
this._super.apply(this, arguments);
|
||||||
var self = this;
|
var self = this;
|
||||||
if (this.datewidget) {
|
if (this.__parentedParent.options.datepicker) {
|
||||||
if (typeof this.options.datepicker === 'object') {
|
var options = this.__parentedParent.options.datepicker;
|
||||||
$.map(this.options.datepicker, function(value, key) {
|
$.each(options, function(value, key) {
|
||||||
self.datewidget.picker('option', key, value);
|
self.options[value] = key;
|
||||||
});
|
self.picker[value] = key;
|
||||||
}
|
self.picker.options[value] = key;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
};
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
<openerp>
|
<odoo>
|
||||||
<data>
|
<template id="assets_backend" name="web_widget_datepicker_options assets" inherit_id="web.assets_backend">
|
||||||
<template id="assets_backend" name="web_widget_datepicker_options assets" inherit_id="web.assets_backend">
|
<xpath expr="." position="inside">
|
||||||
<xpath expr="." position="inside">
|
<script type="text/javascript" src="/web_widget_datepicker_options/static/src/js/datepicker.js"></script>
|
||||||
<script type="text/javascript" src="/web_widget_datepicker_options/static/src/js/datepicker.js"></script>
|
</xpath>
|
||||||
</xpath>
|
</template>
|
||||||
</template>
|
</odoo>
|
||||||
</data>
|
|
||||||
</openerp>
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue