Merge lp:~deepak-willowit/domsense-agilebg-addons/no-lpr into lp:domsense-agilebg-addons/6.1

Proposed by Deepak Seshadri
Status: Needs review
Proposed branch: lp:~deepak-willowit/domsense-agilebg-addons/no-lpr
Merge into: lp:domsense-agilebg-addons/6.1
Diff against target: 58 lines (+24/-5)
2 files modified
base_report_to_printer/printing.py (+8/-5)
base_report_to_printer/security/security.xml (+16/-0)
To merge this branch: bzr merge lp:~deepak-willowit/domsense-agilebg-addons/no-lpr
Reviewer Review Type Date Requested Status
Lorenzo Battistini Needs Resubmitting
Leonardo Pistone (community) Needs Information
Review via email: mp+95849@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Leonardo Pistone (lepistone) wrote :

Deepak,

thanks for your work! could you elaborate a bit on why this is needed?

review: Needs Information
Revision history for this message
Deepak Seshadri (deepak-willowit) wrote :

Hi Leonardo,

It's a lot cleaner to use the methods provided by an API instead of
invoking a system command.

In our case, we have just a proxy forwarding all CUPS connections to
localhost over to a remote server - this setup doest not have a local
version of CUPS's lpr replacement command-line utilities installed,
and hence the addon failed to print any reports. Using the API removes
this requirement, and as I stated earlier, is a lot cleaner.

Regards,

Deepak Seshadri
WillowIT

On 5 March 2012 19:29, Leonardo Pistone - Agile BG - Domsense
<email address hidden> wrote:
> Review: Needs Information
>
> Deepak,
>
> thanks for your work! could you elaborate a bit on why this is needed?
> --
> https://code.launchpad.net/~deepak-willowit/domsense-agilebg-addons/no-lpr/+merge/95849
> You are the owner of lp:~deepak-willowit/domsense-agilebg-addons/no-lpr.

Revision history for this message
Franco Tampieri (dr.dran) wrote :

Hi Deepak,

I believe that the proposed work in this merge is very good, however, would consider at this point, for reasons of flexibility and possibility of different configurations, also the following assumptions:

- Give the option to directly use CUPS or LPR (So who uses windows as LPR server may use base_print_to_report)

- Another important feature would be able to choose the cups server on which to lean, when you can only use the local server

What do you think you can implement these features in your patch to make it more complete?

Best Regards

Franco

Revision history for this message
Willow IT's Code Repository Admin (code-repository) wrote :

Hi Franco,

I certainly agree that the your second suggestion would make the module a lot more useful, but perhaps should be incorporated separately.

However, Using the CUPS API call instead of invoking LPR is guaranteed to work anywhere - even more so as the module uses the CUPS API to retrieve the list of configured printers anyway. I really don't see the advantage of using the LPR command on a system that already has CUPS installed. The LPR replacement command is only available for purposes of retaining backward compatibility so that scripts that depend on LPR already don't break on a system with a modern printing framework such as CUPS.

Regards,

Deepak

Revision history for this message
Franco Tampieri (dr.dran) wrote :

Hi Deepak,

"I really don't see the advantage of using the LPR command on a system that already has CUPS installed. The LPR replacement command is only available for purposes of retaining backward compatibility so that scripts that depend on LPR already don't break on a system with a modern printing framework such as CUPS."

Certainly you're right, but if OpenERP is installed on a windows server, you can not use a CUPS server to use the local printer on the server and I find illogical to create a external CUPS server to interface to the shared printers on that server.

Maintaining compatibility with the old LPR is possible to include a broader spectrum of configurations according to the most various installations.

Regards,

Franco

160. By Deepak Seshadri

[MERGE] New security added for general users.

161. By Deepak Seshadri

[MERGE] raise exception after sending report

Revision history for this message
Franco Tampieri (dr.dran) wrote :

Hi deepak,

we have planned to update the base_report_to_printer module, and we want test your brach on cups installation, and plus we need to insert the lrp compatibility for windows users and next we need to use the python win32 api to interface the module with a windows shared printer on windows native installation.

Tell me something if you agreee with it.

Best Regards

Franco Tampieri

Revision history for this message
Lorenzo Battistini (elbati) wrote :

Hello, please refer to https://launchpad.net/report-print-send project.

review: Needs Resubmitting

Unmerged revisions

161. By Deepak Seshadri

[MERGE] raise exception after sending report

160. By Deepak Seshadri

[MERGE] New security added for general users.

159. By Deepak Seshadri

[FIX] base_report_to_printer

Use the printFile function provided by the CUPS API instead of invoking
the lpr command to actually print the report.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'base_report_to_printer/printing.py'
2--- base_report_to_printer/printing.py 2011-11-16 16:50:17 +0000
3+++ base_report_to_printer/printing.py 2012-05-03 07:14:17 +0000
4@@ -238,13 +238,14 @@
5 printer_system_name = printer
6 else:
7 printer_system_name = printer.system_name
8+
9+ printer_connection = cups.Connection()
10 if format == 'raw':
11- # -l is the same as -o raw
12- cmd = "lpr -l -P %s %s" % (printer_system_name,file_name)
13+ printer_connection.printFile(printer_system_name, file_name, '', {'raw': ''})
14 else:
15- cmd = "lpr -P %s %s" % (printer_system_name,file_name)
16- logger.notifyChannel("report", netsvc.LOG_INFO,"Printing job : '%s'" % cmd)
17- os.system(cmd)
18+ printer_connection.printFile(printer_system_name, file_name, '', {})
19+
20+ logger.notifyChannel("report", netsvc.LOG_INFO,"Printing job: '%s' to '%s'" % (file_name, printer_system_name))
21
22 _inherit = 'ir.actions.report.xml'
23 _columns = {
24@@ -353,6 +354,8 @@
25 and self._reports[report_id].get('format', False)):
26 report_obj.print_direct(cr, uid, base64.encodestring(self._reports[report_id]['result']),
27 self._reports[report_id]['format'], printer)
28+ cr.close()
29+ raise osv.except_osv(_('Printed !'), _("Your print job has been sent to printer '%s'." % (printer.name,)))
30 cr.close()
31
32 res = super(virtual_report_spool, self).exp_report_get(db, uid, report_id)
33
34=== modified file 'base_report_to_printer/security/security.xml'
35--- base_report_to_printer/security/security.xml 2011-09-26 09:48:19 +0000
36+++ base_report_to_printer/security/security.xml 2012-05-03 07:14:17 +0000
37@@ -48,5 +48,21 @@
38 <field eval="0" name="perm_write"/>
39 <field eval="0" name="perm_create"/>
40 </record>
41+ <record id="ir_model_access_printingactionall" model="ir.model.access">
42+ <field name="model_id" ref="model_printing_action"/>
43+ <field eval="1" name="perm_read"/>
44+ <field eval="&quot;&quot;&quot;printing_action all&quot;&quot;&quot;" name="name"/>
45+ <field eval="0" name="perm_unlink"/>
46+ <field eval="0" name="perm_write"/>
47+ <field eval="0" name="perm_create"/>
48+ </record>
49+ <record id="ir_model_access_printingreportxmlactionall" model="ir.model.access">
50+ <field name="model_id" ref="model_printing_report_xml_action"/>
51+ <field eval="1" name="perm_read"/>
52+ <field eval="&quot;&quot;&quot;printing_report_xml_action all&quot;&quot;&quot;" name="name"/>
53+ <field eval="0" name="perm_unlink"/>
54+ <field eval="0" name="perm_write"/>
55+ <field eval="0" name="perm_create"/>
56+ </record>
57 </data>
58 </openerp>

Subscribers

People subscribed via source and target branches

to status/vote changes: