← Back to team overview

openerp-community-reviewer team mailing list archive

[Merge] lp:~therp-nl/web-addons/7.0-add_percentage_widget into lp:web-addons

 

Stefan Rijnhart (Therp) has proposed merging lp:~therp-nl/web-addons/7.0-add_percentage_widget into lp:web-addons.

Requested reviews:
  Web-Addons Core Editors (webaddons-core-editors)

For more details, see:
https://code.launchpad.net/~therp-nl/web-addons/7.0-add_percentage_widget/+merge/217602
-- 
https://code.launchpad.net/~therp-nl/web-addons/7.0-add_percentage_widget/+merge/217602
Your team Web-Addons Core Editors is requested to review the proposed merge of lp:~therp-nl/web-addons/7.0-add_percentage_widget into lp:web-addons.
=== added directory 'web_percent'
=== added file 'web_percent/__init__.py'
--- web_percent/__init__.py	1970-01-01 00:00:00 +0000
+++ web_percent/__init__.py	2014-04-29 13:40:25 +0000
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2014 TeMPO Consulting (<http://www.tempo-consulting.fr>).
+#
+#    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/>.
+#
+##############################################################################

=== added file 'web_percent/__openerp__.py'
--- web_percent/__openerp__.py	1970-01-01 00:00:00 +0000
+++ web_percent/__openerp__.py	2014-04-29 13:40:25 +0000
@@ -0,0 +1,50 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2014 TeMPO Consulting (<http://www.tempo-consulting.fr>).
+#
+#    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': 'Percent widget',
+    'category': 'Web widgets',
+    'author': 'TeMPO Consulting, Therp BV',
+    'description':"""
+Percent widget for form and tree views
+======================================
+
+Add a percentage symbol (%) at the end of float fields
+if widget="percent" is declared in XML.
+
+Known limitations
+=================
+* Editable tree views are not yet supported
+
+""",
+    'version': '2.0',
+    'depends': [
+        "web",
+    ],
+    'js': [
+        'static/src/js/resource.js',
+    ],
+    'css': [],
+    'qweb': [
+        'static/src/xml/percent.xml',
+    ],
+    'auto_install': False,
+    'web_preload': False,
+}

=== added directory 'web_percent/i18n'
=== added directory 'web_percent/static'
=== added directory 'web_percent/static/src'
=== added directory 'web_percent/static/src/js'
=== added file 'web_percent/static/src/js/resource.js'
--- web_percent/static/src/js/resource.js	1970-01-01 00:00:00 +0000
+++ web_percent/static/src/js/resource.js	2014-04-29 13:40:25 +0000
@@ -0,0 +1,45 @@
+/*############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2014 TeMPO Consulting (<http://www.tempo-consulting.fr>),
+#                  2014 Therp BV (<http://therp.nl>).
+#
+#    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/>.
+#
+############################################################################*/
+
+openerp.web_percent = function(instance)
+{
+    /* Form view widget */
+    instance.web.form.FieldPercent = instance.web.form.FieldFloat.extend(
+    {
+        template: "FieldPercent",
+        widget_class: 'oe_form_field_float',
+    });
+    instance.web.form.widgets.add('percent', 'instance.web.form.FieldPercent');
+
+    /* Tree view widget */
+    instance.web.list.Column.include({
+        _format: function (row_data, options) {
+            if (this.widget == 'percent') {
+                // _super behaves differently if widget is set
+                this.widget = undefined;
+                res = this._super(row_data, options) + '%';
+                this.widget = 'percent';
+                return res;
+            }
+            return this._super(row_data, options);
+        }
+    });
+}

=== added directory 'web_percent/static/src/xml'
=== added file 'web_percent/static/src/xml/percent.xml'
--- web_percent/static/src/xml/percent.xml	1970-01-01 00:00:00 +0000
+++ web_percent/static/src/xml/percent.xml	2014-04-29 13:40:25 +0000
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<templates id="template" xml:space="preserve">
+    <t t-name="FieldPercent" t-extend="FieldChar">
+        <t t-jquery="t:last" t-operation="after">
+            %
+        </t>
+    </t>
+ </templates>


Follow ups