Merge lp:~therp-nl/web-addons/7.0-add_percentage_widget into lp:~webaddons-core-editors/web-addons/7.0

Proposed by Stefan Rijnhart (Opener)
Status: Rejected
Rejected by: Stefan Rijnhart (Opener)
Proposed branch: lp:~therp-nl/web-addons/7.0-add_percentage_widget
Merge into: lp:~webaddons-core-editors/web-addons/7.0
Diff against target: 149 lines (+124/-0)
4 files modified
web_percent/__init__.py (+20/-0)
web_percent/__openerp__.py (+50/-0)
web_percent/static/src/js/resource.js (+45/-0)
web_percent/static/src/xml/percent.xml (+9/-0)
To merge this branch: bzr merge lp:~therp-nl/web-addons/7.0-add_percentage_widget
Reviewer Review Type Date Requested Status
Holger Brunn (Therp) Needs Resubmitting
Pedro Manuel Baeza Needs Information
Review via email: mp+217602@code.launchpad.net

Description of the change

Add a simple widget to display floats with a % suffix. Extending a dangling branch from Quentin Theuret (TeMPO).

To post a comment you must log in.
Revision history for this message
Holger Brunn (Therp) (hbrunn) :
review: Approve (code review)
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Hi, Stefan, thanks for continuing Quentin's work. Minimum requirements that I would expect for a percentage widget would be:

- Automatic conversion from float 0.0-1.0 to screen 0.0-100.0 on data read.
- Inverse conversion on data write.
- Validation of the data domain in 0-100 (optionally through an XML parameter).

Don't you think it's worth to include these features from first version?

Regards.

review: Needs Information
Revision history for this message
Holger Brunn (Therp) (hbrunn) wrote :

This project is now hosted on https://github.com/OCA/web. Please move your proposal there. This guide may help you https://github.com/OCA/maintainers-tools/wiki/How-to-move-a-Merge-Proposal-to-GitHub

review: Needs Resubmitting
Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Unmerged revisions

38. By Stefan Rijnhart (Opener)

[ADD] Disclaimer

37. By Stefan Rijnhart (Opener)

[FIX] Preserve original formatting in tree view
[ADD] Credits

36. By Stefan Rijnhart (Opener)

[ADD] Tree view widget

35. By Stefan Rijnhart (Opener)

[RFR] Use instance convention

34. By Quentin THEURET @Amaris

[ADD] Add a new web module that add a new percentage widget that add a percentage symbol after the field value

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== 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 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2014 TeMPO Consulting (<http://www.tempo-consulting.fr>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
021
=== 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 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2014 TeMPO Consulting (<http://www.tempo-consulting.fr>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21{
22 'name': 'Percent widget',
23 'category': 'Web widgets',
24 'author': 'TeMPO Consulting, Therp BV',
25 'description':"""
26Percent widget for form and tree views
27======================================
28
29Add a percentage symbol (%) at the end of float fields
30if widget="percent" is declared in XML.
31
32Known limitations
33=================
34* Editable tree views are not yet supported
35
36""",
37 'version': '2.0',
38 'depends': [
39 "web",
40 ],
41 'js': [
42 'static/src/js/resource.js',
43 ],
44 'css': [],
45 'qweb': [
46 'static/src/xml/percent.xml',
47 ],
48 'auto_install': False,
49 'web_preload': False,
50}
051
=== 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 @@
1/*############################################################################
2#
3# OpenERP, Open Source Management Solution
4# Copyright (C) 2014 TeMPO Consulting (<http://www.tempo-consulting.fr>),
5# 2014 Therp BV (<http://therp.nl>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20############################################################################*/
21
22openerp.web_percent = function(instance)
23{
24 /* Form view widget */
25 instance.web.form.FieldPercent = instance.web.form.FieldFloat.extend(
26 {
27 template: "FieldPercent",
28 widget_class: 'oe_form_field_float',
29 });
30 instance.web.form.widgets.add('percent', 'instance.web.form.FieldPercent');
31
32 /* Tree view widget */
33 instance.web.list.Column.include({
34 _format: function (row_data, options) {
35 if (this.widget == 'percent') {
36 // _super behaves differently if widget is set
37 this.widget = undefined;
38 res = this._super(row_data, options) + '%';
39 this.widget = 'percent';
40 return res;
41 }
42 return this._super(row_data, options);
43 }
44 });
45}
046
=== 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 @@
1<?xml version="1.0" encoding="UTF-8" ?>
2
3<templates id="template" xml:space="preserve">
4 <t t-name="FieldPercent" t-extend="FieldChar">
5 <t t-jquery="t:last" t-operation="after">
6 %
7 </t>
8 </t>
9 </templates>

Subscribers

People subscribed via source and target branches