Merge lp:~pcsol/openobject-server/print_trunk into lp:openobject-server

Proposed by Cédric Krier
Status: Rejected
Rejected by: Vo Minh Thu
Proposed branch: lp:~pcsol/openobject-server/print_trunk
Merge into: lp:openobject-server
Diff against target: 100 lines (+20/-5)
5 files modified
bin/addons/base/ir/ir.xml (+2/-0)
bin/addons/base/ir/ir_actions.py (+3/-0)
bin/report/interface.py (+8/-2)
bin/report/report_sxw.py (+2/-2)
bin/service/web_services.py (+5/-1)
To merge this branch: bzr merge lp:~pcsol/openobject-server/print_trunk
Reviewer Review Type Date Requested Status
xrg (community) Abstain
Christophe CHAUVET (community) Approve
Review via email: mp+31519@code.launchpad.net

Description of the change

Add number and email in report result to use with the client from lp:~pcsol/openobject-client/print_trunk

To post a comment you must log in.
Revision history for this message
Christophe CHAUVET (christophe-chauvet) wrote :

It work for me

Regards,

review: Approve
Revision history for this message
xrg (xrg) wrote :

I would prefer that extra fields in reports are defined in an addon, eg. like the code I have had since Dec. 2008, account_greek_fiscal

http://git.hellug.gr/?p=xrg/openobject-addons;a=blob;f=account_greek_fiscal/ir_actions_report.py;h=7b257d23020dd1f86e6d5ae9dd6232e231d29b18;hb=refs/heads/trunk-xrg

Said that, we can still discuss your proposal.

review: Abstain
Revision history for this message
Vo Minh Thu (thu) wrote :

I'm a bit puzzled by this merge prop, and the 'It work for me' comment... (I would have been happy to discuss the proposal but xrg's comment remains alone. Also, this code adds more than the two mentioned field: an seemingly unused attachment_use; more importantly the variable number will be uninitialized (numner, instead of number, is initialized).

Unmerged revisions

2570. By Cédric Krier

Add number and email in report result

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bin/addons/base/ir/ir.xml'
--- bin/addons/base/ir/ir.xml 2010-07-23 06:17:04 +0000
+++ bin/addons/base/ir/ir.xml 2010-08-02 08:17:44 +0000
@@ -341,6 +341,8 @@
341 <field name="report_rml"/>341 <field name="report_rml"/>
342 <field name="header"/>342 <field name="header"/>
343 <field name="auto"/>343 <field name="auto"/>
344 <field name="number"/>
345 <field name="email" colspan="3"/>
344 </group>346 </group>
345 <group col="2" colspan="2">347 <group col="2" colspan="2">
346 <separator string="XML Report" colspan="2"/>348 <separator string="XML Report" colspan="2"/>
347349
=== modified file 'bin/addons/base/ir/ir_actions.py'
--- bin/addons/base/ir/ir_actions.py 2010-07-28 07:17:23 +0000
+++ bin/addons/base/ir/ir_actions.py 2010-08-02 08:17:44 +0000
@@ -117,6 +117,9 @@
117 'report_sxw_content': fields.function(_report_content, fnct_inv=_report_content_inv, method=True, type='binary', string='SXW content',),117 'report_sxw_content': fields.function(_report_content, fnct_inv=_report_content_inv, method=True, type='binary', string='SXW content',),
118 'report_rml_content': fields.function(_report_content, fnct_inv=_report_content_inv, method=True, type='binary', string='RML content'),118 'report_rml_content': fields.function(_report_content, fnct_inv=_report_content_inv, method=True, type='binary', string='RML content'),
119119
120 'attachment_use': fields.boolean('Reload from Attachment', help='If you check this, then the second time the user prints with same attachment name, it returns the previous report.'),
121 'number': fields.integer('Copy Number'),
122 'email': fields.char('Email', size=256),
120 }123 }
121 _defaults = {124 _defaults = {
122 'type': lambda *a: 'ir.actions.report.xml',125 'type': lambda *a: 'ir.actions.report.xml',
123126
=== modified file 'bin/report/interface.py'
--- bin/report/interface.py 2010-03-30 11:30:26 +0000
+++ bin/report/interface.py 2010-08-02 08:17:44 +0000
@@ -94,10 +94,16 @@
94 pool = pooler.get_pool(cr.dbname)94 pool = pooler.get_pool(cr.dbname)
95 ir_actions_report_xml_obj = pool.get('ir.actions.report.xml')95 ir_actions_report_xml_obj = pool.get('ir.actions.report.xml')
96 report_xml_ids = ir_actions_report_xml_obj.search(cr, uid, [('report_name', '=', self.name[7:])], context=context)96 report_xml_ids = ir_actions_report_xml_obj.search(cr, uid, [('report_name', '=', self.name[7:])], context=context)
97 self.title = report_xml_ids and ir_actions_report_xml_obj.browse(cr,uid,report_xml_ids)[0].name or 'OpenERP Report'97 self.title = 'OpenERP Report'
98 numner = 1
99 if report_xml_ids:
100 report = ir_actions_report_xml_obj.browse(cr, uid, report_xml_ids[0],
101 context=context)
102 self.title = report.name
103 numner = report.number
98 create_doc = self.generators[report_type]104 create_doc = self.generators[report_type]
99 pdf = create_doc(rml, title=self.title)105 pdf = create_doc(rml, title=self.title)
100 return (pdf, report_type)106 return (pdf, report_type, self.title, number)
101107
102 def create_xml(self, cr, uid, ids, datas, context=None):108 def create_xml(self, cr, uid, ids, datas, context=None):
103 if not context:109 if not context:
104110
=== modified file 'bin/report/report_sxw.py'
--- bin/report/report_sxw.py 2010-07-16 07:34:53 +0000
+++ bin/report/report_sxw.py 2010-08-02 08:17:44 +0000
@@ -347,7 +347,7 @@
347 def __init__(self, *args, **argv):347 def __init__(self, *args, **argv):
348 for key,arg in argv.items():348 for key,arg in argv.items():
349 setattr(self, key, arg)349 setattr(self, key, arg)
350 report_xml = a(title=title, report_type=report_type, report_rml_content=rml, name=title, attachment=False, header=self.header)350 report_xml = a(title=title, report_type=report_type, report_rml_content=rml, name=title, attachment=False, header=self.header, number=1)
351 report_type = report_xml.report_type351 report_type = report_xml.report_type
352 if report_type in ['sxw','odt']:352 if report_type in ['sxw','odt']:
353 fnct = self.create_source_odt353 fnct = self.create_source_odt
@@ -362,7 +362,7 @@
362 fnct_ret = fnct(cr, uid, ids, data, report_xml, context)362 fnct_ret = fnct(cr, uid, ids, data, report_xml, context)
363 if not fnct_ret:363 if not fnct_ret:
364 return (False,False)364 return (False,False)
365 return fnct_ret365 return fnct_ret + (report_xml.name, report_xml.number)
366366
367 def create_source_odt(self, cr, uid, ids, data, report_xml, context=None):367 def create_source_odt(self, cr, uid, ids, data, report_xml, context=None):
368 return self.create_single_odt(cr, uid, ids, data, report_xml, context or {})368 return self.create_single_odt(cr, uid, ids, data, report_xml, context or {})
369369
=== modified file 'bin/service/web_services.py'
--- bin/service/web_services.py 2010-07-27 15:22:11 +0000
+++ bin/service/web_services.py 2010-08-02 08:17:44 +0000
@@ -706,13 +706,15 @@
706 import sys706 import sys
707 try:707 try:
708 obj = netsvc.LocalService('report.'+object)708 obj = netsvc.LocalService('report.'+object)
709 (result, format) = obj.create(cr, uid, ids, datas, context)709 (result, format, name, number) = obj.create(cr, uid, ids, datas, context)
710 if not result:710 if not result:
711 tb = sys.exc_info()711 tb = sys.exc_info()
712 self._reports[id]['exception'] = ExceptionWithTraceback('RML is not available at specified location or not enough data to print!', tb)712 self._reports[id]['exception'] = ExceptionWithTraceback('RML is not available at specified location or not enough data to print!', tb)
713 self._reports[id]['result'] = result713 self._reports[id]['result'] = result
714 self._reports[id]['format'] = format714 self._reports[id]['format'] = format
715 self._reports[id]['state'] = True715 self._reports[id]['state'] = True
716 self._reports[id]['name'] = name
717 self._reports[id]['number'] = number
716 except Exception, exception:718 except Exception, exception:
717 719
718 tb = sys.exc_info()720 tb = sys.exc_info()
@@ -748,6 +750,8 @@
748 if res2:750 if res2:
749 res['result'] = base64.encodestring(res2)751 res['result'] = base64.encodestring(res2)
750 res['format'] = result['format']752 res['format'] = result['format']
753 res['name'] = result['name']
754 res['number'] = result['number']
751 del self._reports[report_id]755 del self._reports[report_id]
752 return res756 return res
753757