mirror of https://github.com/OCA/web.git
commit
81f2df1a89
|
@ -0,0 +1 @@
|
||||||
|
__import__('pkg_resources').declare_namespace(__name__)
|
|
@ -0,0 +1 @@
|
||||||
|
../../../web_widget_color
|
|
@ -0,0 +1,6 @@
|
||||||
|
import setuptools
|
||||||
|
|
||||||
|
setuptools.setup(
|
||||||
|
setup_requires=['setuptools-odoo'],
|
||||||
|
odoo_addon=True,
|
||||||
|
)
|
|
@ -27,12 +27,6 @@ Features
|
||||||
|listview|
|
|listview|
|
||||||
|
|
||||||
|
|
||||||
Requirements
|
|
||||||
============
|
|
||||||
|
|
||||||
This module has been ported to 8.0
|
|
||||||
|
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
=====
|
=====
|
||||||
|
|
||||||
|
@ -87,6 +81,7 @@ Contributors
|
||||||
------------
|
------------
|
||||||
|
|
||||||
* Adil Houmadi <adil.houmadi@gmail.com>
|
* Adil Houmadi <adil.houmadi@gmail.com>
|
||||||
|
* Nicolas JEUDY (Sudokeys) <https://www.github.com/njeudy>
|
||||||
|
|
||||||
Maintainer
|
Maintainer
|
||||||
----------
|
----------
|
||||||
|
|
|
@ -1,25 +1,2 @@
|
||||||
# -*- encoding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
############################################################################
|
|
||||||
#
|
#
|
||||||
# Odoo, Open Source Web Color
|
|
||||||
# Copyright (C) 2012 Savoir-faire Linux (<http://www.savoirfairelinux.com>).
|
|
||||||
# Copyright (C) 2014 Anybox <http://anybox.fr>
|
|
||||||
# Copyright (C) 2015 Taktik SA <http://taktik.be>
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU 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 General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
# @author Étienne Beaudry Auger <etienne.b.auger@savoirfairelinux.com>
|
|
||||||
# @author Adil Houmadi <ah@taktik.be>
|
|
||||||
#
|
|
||||||
##############################################################################
|
|
||||||
|
|
|
@ -1,35 +1,18 @@
|
||||||
# -*- encoding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
############################################################################
|
|
||||||
#
|
|
||||||
# Odoo, Open Source Web Widget Color
|
# Odoo, Open Source Web Widget Color
|
||||||
# Copyright (C) 2012 Savoir-faire Linux (<http://www.savoirfairelinux.com>).
|
# Copyright (C) 2012 Savoir-faire Linux (<http://www.savoirfairelinux.com>).
|
||||||
# Copyright (C) 2014 Anybox <http://anybox.fr>
|
# Copyright (C) 2014 Anybox <http://anybox.fr>
|
||||||
# Copyright (C) 2015 Taktik SA <http://taktik.be>
|
# Copyright (C) 2015 Taktik SA <http://taktik.be>
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).#
|
||||||
# it under the terms of the GNU 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 General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
# @author Étienne Beaudry Auger <etienne.b.auger@savoirfairelinux.com>
|
|
||||||
# @author Adil Houmadi <ah@taktik.be>
|
|
||||||
#
|
|
||||||
##############################################################################
|
|
||||||
{
|
{
|
||||||
'name': "Web Widget Color",
|
'name': "Web Widget Color",
|
||||||
'category': "web",
|
'category': "web",
|
||||||
'version': "8.0.1.0.0",
|
'version': "9.0.1.0.0",
|
||||||
"author": "Savoir-faire Linux, "
|
"author": "Savoir-faire Linux, "
|
||||||
"Anybox, "
|
"Anybox, "
|
||||||
"Taktik SA, "
|
"Taktik SA, "
|
||||||
|
"Sudokeys, "
|
||||||
"Odoo Community Association (OCA)",
|
"Odoo Community Association (OCA)",
|
||||||
'depends': ['base', 'web'],
|
'depends': ['base', 'web'],
|
||||||
'data': [
|
'data': [
|
||||||
|
@ -38,7 +21,8 @@
|
||||||
'qweb': [
|
'qweb': [
|
||||||
'static/src/xml/widget.xml',
|
'static/src/xml/widget.xml',
|
||||||
],
|
],
|
||||||
|
'license': 'AGPL-3',
|
||||||
'auto_install': False,
|
'auto_install': False,
|
||||||
'installable': False,
|
'installable': True,
|
||||||
'web_preload': True,
|
'web_preload': True,
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,3 +21,10 @@
|
||||||
top: 3px;
|
top: 3px;
|
||||||
width: 40px;
|
width: 40px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.color_box {
|
||||||
|
width: 10px;
|
||||||
|
height: 10px;
|
||||||
|
display: inline-block;
|
||||||
|
margin-right: 5px;
|
||||||
|
}
|
||||||
|
|
|
@ -1,4 +1,12 @@
|
||||||
openerp.web_widget_color = function (instance) {
|
odoo.define('web.web_widget_color', function(require) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var core = require('web.core');
|
||||||
|
var widget = require('web.form_widgets');
|
||||||
|
var FormView = require('web.FormView');
|
||||||
|
|
||||||
|
var QWeb = core.qweb;
|
||||||
|
var _lt = core._lt;
|
||||||
|
|
||||||
var _super_getDir = jscolor.getDir.prototype;
|
var _super_getDir = jscolor.getDir.prototype;
|
||||||
jscolor.getDir = function () {
|
jscolor.getDir = function () {
|
||||||
|
@ -9,11 +17,7 @@ openerp.web_widget_color = function (instance) {
|
||||||
return jscolor.dir;
|
return jscolor.dir;
|
||||||
};
|
};
|
||||||
|
|
||||||
instance.web.form.widgets.add('color', 'instance.web.form.FieldColor');
|
var FieldColor = widget.FieldChar.extend({
|
||||||
|
|
||||||
instance.web.search.fields.add('color', 'instance.web.search.CharField');
|
|
||||||
|
|
||||||
instance.web.form.FieldColor = instance.web.form.FieldChar.extend({
|
|
||||||
template: 'FieldColor',
|
template: 'FieldColor',
|
||||||
widget_class: 'oe_form_field_color',
|
widget_class: 'oe_form_field_color',
|
||||||
is_syntax_valid: function () {
|
is_syntax_valid: function () {
|
||||||
|
@ -33,27 +37,48 @@ openerp.web_widget_color = function (instance) {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
store_dom_value: function() {
|
||||||
|
if (!this.silent) {
|
||||||
|
if (!this.get('effective_readonly') &&
|
||||||
|
this.$('input').val() !== '' &&
|
||||||
|
this.is_syntax_valid()) {
|
||||||
|
// We use internal_set_value because we were called by
|
||||||
|
// ``.commit_value()`` which is called by a ``.set_value()``
|
||||||
|
// itself called because of a ``onchange`` event
|
||||||
|
this.internal_set_value(
|
||||||
|
this.parse_value(
|
||||||
|
this.$('input').val())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
render_value: function () {
|
render_value: function () {
|
||||||
var show_value = this.format_value(this.get('value'), '');
|
var show_value = this.format_value(this.get('value'), '');
|
||||||
if (!this.get("effective_readonly")) {
|
if (!this.get("effective_readonly")) {
|
||||||
var $input = this.$el.find('input');
|
var $input = this.$el.find('input');
|
||||||
$input.val(show_value);
|
$input.val(show_value);
|
||||||
$input.css("background-color", show_value)
|
$input.css("background-color", show_value);
|
||||||
jscolor.init(this.$el[0]);
|
jscolor.init(this.$el[0]);
|
||||||
} else {
|
} else {
|
||||||
this.$(".oe_form_char_content").text(show_value);
|
this.$(".oe_form_char_content").text(show_value);
|
||||||
this.$('div').css("background-color", show_value)
|
this.$('div').css("background-color", show_value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
core.form_widget_registry.add('color', FieldColor);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Init jscolor for each editable mode on view form
|
* Init jscolor for each editable mode on view form
|
||||||
*/
|
*/
|
||||||
instance.web.FormView.include({
|
FormView.include({
|
||||||
to_edit_mode: function () {
|
to_edit_mode: function () {
|
||||||
this._super();
|
this._super();
|
||||||
jscolor.init(this.$el[0]);
|
jscolor.init(this.$el[0]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
|
||||||
|
return {
|
||||||
|
FieldColor: FieldColor
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
|
@ -19,6 +19,6 @@
|
||||||
</span>
|
</span>
|
||||||
</t>
|
</t>
|
||||||
<tr t-extend="ListView.row">
|
<tr t-extend="ListView.row">
|
||||||
<t t-jquery="t td t" t-operation="replace"><t t-if="column.widget =='color' || column.type == 'color'"><div t-att-style="'background-color:' + render_cell(record, column)"/></t><t t-raw="render_cell(record, column)"/></t>
|
<t t-jquery="t td t" t-operation="replace"><t t-if="column.widget =='color' || column.type == 'color'"><div class="color_box" t-att-style="'background-color:' + render_cell(record, column)"/></t><t t-raw="render_cell(record, column)"/></t>
|
||||||
</tr>
|
</tr>
|
||||||
</templates>
|
</templates>
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<openerp>
|
<odoo>
|
||||||
<data>
|
<template id="assets_backend" name="web_widget_color assets" inherit_id="web.assets_backend">
|
||||||
<template id="assets_backend" name="web_widget_color assets" inherit_id="web.assets_backend">
|
<xpath expr="." position="inside">
|
||||||
<xpath expr="." position="inside">
|
<link rel="stylesheet" href="/web_widget_color/static/src/css/widget.css"/>
|
||||||
<link rel="stylesheet" href="/web_widget_color/static/src/css/widget.css"/>
|
<script type="text/javascript" src="/web_widget_color/static/lib/jscolor/jscolor.js"></script>
|
||||||
<script type="text/javascript" src="/web_widget_color/static/lib/jscolor/jscolor.js"></script>
|
<script type="text/javascript" src="/web_widget_color/static/src/js/widget.js"></script>
|
||||||
<script type="text/javascript" src="/web_widget_color/static/src/js/widget.js"></script>
|
</xpath>
|
||||||
</xpath>
|
</template>
|
||||||
</template>
|
</odoo>
|
||||||
</data>
|
|
||||||
</openerp>
|
|
||||||
|
|
Loading…
Reference in New Issue