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
1=== added directory 'web_percent'
2=== added file 'web_percent/__init__.py'
3--- web_percent/__init__.py 1970-01-01 00:00:00 +0000
4+++ web_percent/__init__.py 2014-04-29 13:40:25 +0000
5@@ -0,0 +1,20 @@
6+# -*- coding: utf-8 -*-
7+##############################################################################
8+#
9+# OpenERP, Open Source Management Solution
10+# Copyright (C) 2014 TeMPO Consulting (<http://www.tempo-consulting.fr>).
11+#
12+# This program is free software: you can redistribute it and/or modify
13+# it under the terms of the GNU Affero General Public License as
14+# published by the Free Software Foundation, either version 3 of the
15+# License, or (at your option) any later version.
16+#
17+# This program is distributed in the hope that it will be useful,
18+# but WITHOUT ANY WARRANTY; without even the implied warranty of
19+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+# GNU Affero General Public License for more details.
21+#
22+# You should have received a copy of the GNU Affero General Public License
23+# along with this program. If not, see <http://www.gnu.org/licenses/>.
24+#
25+##############################################################################
26
27=== added file 'web_percent/__openerp__.py'
28--- web_percent/__openerp__.py 1970-01-01 00:00:00 +0000
29+++ web_percent/__openerp__.py 2014-04-29 13:40:25 +0000
30@@ -0,0 +1,50 @@
31+# -*- coding: utf-8 -*-
32+##############################################################################
33+#
34+# OpenERP, Open Source Management Solution
35+# Copyright (C) 2014 TeMPO Consulting (<http://www.tempo-consulting.fr>).
36+#
37+# This program is free software: you can redistribute it and/or modify
38+# it under the terms of the GNU Affero General Public License as
39+# published by the Free Software Foundation, either version 3 of the
40+# License, or (at your option) any later version.
41+#
42+# This program is distributed in the hope that it will be useful,
43+# but WITHOUT ANY WARRANTY; without even the implied warranty of
44+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45+# GNU Affero General Public License for more details.
46+#
47+# You should have received a copy of the GNU Affero General Public License
48+# along with this program. If not, see <http://www.gnu.org/licenses/>.
49+#
50+##############################################################################
51+{
52+ 'name': 'Percent widget',
53+ 'category': 'Web widgets',
54+ 'author': 'TeMPO Consulting, Therp BV',
55+ 'description':"""
56+Percent widget for form and tree views
57+======================================
58+
59+Add a percentage symbol (%) at the end of float fields
60+if widget="percent" is declared in XML.
61+
62+Known limitations
63+=================
64+* Editable tree views are not yet supported
65+
66+""",
67+ 'version': '2.0',
68+ 'depends': [
69+ "web",
70+ ],
71+ 'js': [
72+ 'static/src/js/resource.js',
73+ ],
74+ 'css': [],
75+ 'qweb': [
76+ 'static/src/xml/percent.xml',
77+ ],
78+ 'auto_install': False,
79+ 'web_preload': False,
80+}
81
82=== added directory 'web_percent/i18n'
83=== added directory 'web_percent/static'
84=== added directory 'web_percent/static/src'
85=== added directory 'web_percent/static/src/js'
86=== added file 'web_percent/static/src/js/resource.js'
87--- web_percent/static/src/js/resource.js 1970-01-01 00:00:00 +0000
88+++ web_percent/static/src/js/resource.js 2014-04-29 13:40:25 +0000
89@@ -0,0 +1,45 @@
90+/*############################################################################
91+#
92+# OpenERP, Open Source Management Solution
93+# Copyright (C) 2014 TeMPO Consulting (<http://www.tempo-consulting.fr>),
94+# 2014 Therp BV (<http://therp.nl>).
95+#
96+# This program is free software: you can redistribute it and/or modify
97+# it under the terms of the GNU Affero General Public License as
98+# published by the Free Software Foundation, either version 3 of the
99+# License, or (at your option) any later version.
100+#
101+# This program is distributed in the hope that it will be useful,
102+# but WITHOUT ANY WARRANTY; without even the implied warranty of
103+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
104+# GNU Affero General Public License for more details.
105+#
106+# You should have received a copy of the GNU Affero General Public License
107+# along with this program. If not, see <http://www.gnu.org/licenses/>.
108+#
109+############################################################################*/
110+
111+openerp.web_percent = function(instance)
112+{
113+ /* Form view widget */
114+ instance.web.form.FieldPercent = instance.web.form.FieldFloat.extend(
115+ {
116+ template: "FieldPercent",
117+ widget_class: 'oe_form_field_float',
118+ });
119+ instance.web.form.widgets.add('percent', 'instance.web.form.FieldPercent');
120+
121+ /* Tree view widget */
122+ instance.web.list.Column.include({
123+ _format: function (row_data, options) {
124+ if (this.widget == 'percent') {
125+ // _super behaves differently if widget is set
126+ this.widget = undefined;
127+ res = this._super(row_data, options) + '%';
128+ this.widget = 'percent';
129+ return res;
130+ }
131+ return this._super(row_data, options);
132+ }
133+ });
134+}
135
136=== added directory 'web_percent/static/src/xml'
137=== added file 'web_percent/static/src/xml/percent.xml'
138--- web_percent/static/src/xml/percent.xml 1970-01-01 00:00:00 +0000
139+++ web_percent/static/src/xml/percent.xml 2014-04-29 13:40:25 +0000
140@@ -0,0 +1,9 @@
141+<?xml version="1.0" encoding="UTF-8" ?>
142+
143+<templates id="template" xml:space="preserve">
144+ <t t-name="FieldPercent" t-extend="FieldChar">
145+ <t t-jquery="t:last" t-operation="after">
146+ %
147+ </t>
148+ </t>
149+ </templates>

Subscribers

People subscribed via source and target branches