Merge lp:~openerp-dev/openerp-web/trunk-web_pdf_reports_inbuilt-pga into lp:openerp-web

Proposed by Parth Gajjar(Open ERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openerp-web/trunk-web_pdf_reports_inbuilt-pga
Merge into: lp:openerp-web
Diff against target: 198 lines (+120/-38)
3 files modified
addons/web/controllers/main.py (+8/-6)
addons/web/static/src/css/base.css (+43/-0)
addons/web/static/src/js/core.js (+69/-32)
To merge this branch: bzr merge lp:~openerp-dev/openerp-web/trunk-web_pdf_reports_inbuilt-pga
Reviewer Review Type Date Requested Status
Mantavya Gajjar (Open ERP) (community) Needs Information
OpenERP R&D Web Team Pending
Review via email: mp+178658@code.launchpad.net

Description of the change

Hello,
Added inbuilt pdf view feature.
Thanks,
PGA

To post a comment you must log in.
Revision history for this message
Mantavya Gajjar (Open ERP) (mga) wrote :

Make a good text on module description and change the text on settings menu

Replace (View Report -> Enable this for open PDF reports in browser.)

With (View Report -> Enable this to have inline pdf report viewer.)

or some good text

review: Needs Information
3789. By Parth Gajjar(Open ERP)

merged with trunk-web

3790. By Parth Gajjar(Open ERP)

[ADD] inbuilt pdf view feature in core.js (due to conflict)

3791. By Parth Gajjar(Open ERP)

merged with trunk-web

Unmerged revisions

3791. By Parth Gajjar(Open ERP)

merged with trunk-web

3790. By Parth Gajjar(Open ERP)

[ADD] inbuilt pdf view feature in core.js (due to conflict)

3789. By Parth Gajjar(Open ERP)

merged with trunk-web

3788. By Parth Gajjar(Open ERP)

merged with latest trunk

3787. By Parth Gajjar(Open ERP)

[IMP] improved code

3786. By Parth Gajjar(Open ERP)

[IMP] improved code

3785. By Parth Gajjar(Open ERP)

[ADD] Added inbuilt pdf view feature

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'addons/web/controllers/main.py'
2--- addons/web/controllers/main.py 2013-09-24 15:19:13 +0000
3+++ addons/web/controllers/main.py 2013-09-30 10:53:14 +0000
4@@ -1723,12 +1723,14 @@
5 else:
6 file_name = action['report_name']
7 file_name = '%s.%s' % (file_name, report_struct['format'])
8-
9+ headers=[
10+ ('Content-Disposition', content_disposition(file_name)),
11+ ('Content-Type', report_mimetype),
12+ ('Content-Length', len(report))]
13+ if action.get('inbuilt_pdf',False):
14+ del headers[0]
15 return request.make_response(report,
16- headers=[
17- ('Content-Disposition', content_disposition(file_name)),
18- ('Content-Type', report_mimetype),
19- ('Content-Length', len(report))],
20- cookies={'fileToken': token})
21+ headers = headers,
22+ cookies = {'fileToken': token})
23
24 # vim:expandtab:tabstop=4:softtabstop=4:shiftwidth=4:
25
26=== modified file 'addons/web/static/src/css/base.css'
27--- addons/web/static/src/css/base.css 2013-09-04 13:24:30 +0000
28+++ addons/web/static/src/css/base.css 2013-09-30 10:53:14 +0000
29@@ -3430,6 +3430,49 @@
30 filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#EFEFEF', endColorstr='#D8D8D8');
31 }
32
33+.openerp div.close_print{
34+ display: block;
35+ text-shadow: 1px 1px 5px #050505;
36+ filter: dropshadow(color=#050505, offx=1, offy=1);
37+ line-height:50px;
38+ width:50px;
39+ position:fixed;
40+ right:2em;
41+ top:7em;
42+ color:#C3C3C3;
43+ background: #3f3f3f; /* Old browsers */
44+ background: -moz-linear-gradient(top, #3f3f3f 0%, #0e0e0e 100%); /* FF3.6+ */
45+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#3f3f3f), color-stop(100%,#0e0e0e)); /* Chrome,Safari4+ */
46+ background: -webkit-linear-gradient(top, #3f3f3f 0%,#0e0e0e 100%); /* Chrome10+,Safari5.1+ */
47+ background: -o-linear-gradient(top, #3f3f3f 0%,#0e0e0e 100%); /* Opera 11.10+ */
48+ background: -ms-linear-gradient(top, #3f3f3f 0%,#0e0e0e 100%); /* IE10+ */
49+ background: linear-gradient(to bottom, #3f3f3f 0%,#0e0e0e 100%); /* W3C */
50+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#3f3f3f', endColorstr='#0e0e0e',GradientType=0 ); /* IE6-9 */
51+ -webkit-border-radius: 100px 100px 100px 100px;
52+ border-radius: 100px 100px 100px 100px;
53+}
54+
55+.openerp div.close_print div{
56+ text-align:center;
57+ -webkit-transition: font-size 0.1s;
58+ -moz-transition: font-size 0.1s;
59+ -ms-transition: font-size 0.1s;
60+ -o-transition: font-size 0.1s;
61+ transition: font-size 0.1s;
62+}
63+.openerp div.close_print div div{
64+ visibility:visible;
65+ font-family: "entypoRegular";
66+ font-size: 4em;
67+ padding-top:0px;
68+}
69+
70+.openerp div.close_print:hover div div{
71+ text-align:center;
72+ font-size: 6em;
73+}
74+
75+
76 @media print {
77 .openerp {
78 text-shadow: none;
79
80=== modified file 'addons/web/static/src/js/core.js'
81--- addons/web/static/src/js/core.js 2013-08-07 09:22:32 +0000
82+++ addons/web/static/src/js/core.js 2013-09-30 10:53:14 +0000
83@@ -459,6 +459,8 @@
84
85 // iOS devices doesn't allow iframe use the way we do it,
86 // opening a new window seems the best way to workaround
87+ action = JSON.parse(options.data.action)
88+ var inbuilt_pdf = action.inbuilt_pdf;
89 if (navigator.userAgent.match(/(iPod|iPhone|iPad)/)) {
90 var params = _.extend({}, options.data || {}, {token: token});
91 var url = this.url(options.url, params);
92@@ -470,39 +472,74 @@
93
94 var complete = function () {
95 if (options.complete) { options.complete(); }
96- clearTimeout(timer);
97- $form_data.remove();
98- $target.remove();
99- if (remove_form && $form) { $form.remove(); }
100+ if (!inbuilt_pdf){
101+ clearTimeout(timer);
102+ $form_data.remove();
103+ $target.remove();
104+ if (remove_form && $form) { $form.remove(); }
105+ }
106 };
107- var $target = $('<iframe style="display: none;">')
108- .attr({id: id, name: id})
109- .appendTo(document.body)
110- .load(function () {
111- try {
112- if (options.error) {
113- if (!this.contentDocument.body.childNodes[1]) {
114- options.error(this.contentDocument.body.childNodes);
115- }
116- else {
117- options.error(JSON.parse(this.contentDocument.body.childNodes[1].textContent));
118- }
119- }
120- } finally {
121- complete();
122- }
123- });
124-
125- if (options.form) {
126- $form = $(options.form);
127- } else {
128- remove_form = true;
129- $form = $('<form>', {
130- action: options.url,
131- method: 'POST'
132- }).appendTo(document.body);
133- }
134-
135+ if (!inbuilt_pdf){
136+ var $target = $('<iframe style="display: none;">')
137+ .attr({id: id, name: id})
138+ .appendTo(document.body)
139+ .load(function () {
140+ try {
141+ if (options.error) {
142+ if (!this.contentDocument.body.childNodes[1]) {
143+ options.error(this.contentDocument.body.childNodes);
144+ }
145+ else {
146+ options.error(JSON.parse(this.contentDocument.body.childNodes[1].textContent));
147+ }
148+ }
149+ } finally {
150+ complete();
151+ }
152+ });
153+
154+ if (options.form) {
155+ $form = $(options.form);
156+ } else {
157+ remove_form = true;
158+ $form = $('<form>', {
159+ action: options.url,
160+ method: 'POST'
161+ }).appendTo(document.body);
162+ }
163+ }
164+ else{
165+ $('.oe_view_manager.oe_view_manager_current').children().hide();
166+ var height_window = ($(window).height()) - 32;
167+ var $target = $('<iframe style="top:100px;left:1px;z-index:500;width:100%;height:' + height_window + 'px;">')
168+ .attr({id: id, name: id})
169+ .prependTo(".oe_view_manager.oe_view_manager_current")
170+ .load(function () {
171+ $('<a><div class="close_print"><div><div>X</div><i>Close</i></div></div></a>')
172+ .attr({ id: 'close_print'})
173+ .prependTo(".oe_view_manager.oe_view_manager_current");
174+ $("#close_print")
175+ .click(function () {
176+ clearTimeout(timer);
177+ $form_data.remove();
178+ $target.remove();
179+ if (remove_form && $form) {
180+ $form.remove();
181+ }
182+ $("#close_print").remove();
183+ $('.oe_view_manager.oe_view_manager_current').children().show();
184+ });
185+ });
186+ if (options.form) {
187+ $form = $(options.form);
188+ } else {
189+ remove_form = true;
190+ $form = $('<form>', {
191+ action: options.url,
192+ method: 'GET'
193+ }).appendTo(document.body);
194+ }
195+ }
196 var hparams = _.extend({}, options.data || {}, {token: token});
197 if (this.override_session)
198 hparams.session_id = this.session_id;