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
1=== modified file 'bin/addons/base/ir/ir.xml'
2--- bin/addons/base/ir/ir.xml 2010-07-23 06:17:04 +0000
3+++ bin/addons/base/ir/ir.xml 2010-08-02 08:17:44 +0000
4@@ -341,6 +341,8 @@
5 <field name="report_rml"/>
6 <field name="header"/>
7 <field name="auto"/>
8+ <field name="number"/>
9+ <field name="email" colspan="3"/>
10 </group>
11 <group col="2" colspan="2">
12 <separator string="XML Report" colspan="2"/>
13
14=== modified file 'bin/addons/base/ir/ir_actions.py'
15--- bin/addons/base/ir/ir_actions.py 2010-07-28 07:17:23 +0000
16+++ bin/addons/base/ir/ir_actions.py 2010-08-02 08:17:44 +0000
17@@ -117,6 +117,9 @@
18 'report_sxw_content': fields.function(_report_content, fnct_inv=_report_content_inv, method=True, type='binary', string='SXW content',),
19 'report_rml_content': fields.function(_report_content, fnct_inv=_report_content_inv, method=True, type='binary', string='RML content'),
20
21+ '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.'),
22+ 'number': fields.integer('Copy Number'),
23+ 'email': fields.char('Email', size=256),
24 }
25 _defaults = {
26 'type': lambda *a: 'ir.actions.report.xml',
27
28=== modified file 'bin/report/interface.py'
29--- bin/report/interface.py 2010-03-30 11:30:26 +0000
30+++ bin/report/interface.py 2010-08-02 08:17:44 +0000
31@@ -94,10 +94,16 @@
32 pool = pooler.get_pool(cr.dbname)
33 ir_actions_report_xml_obj = pool.get('ir.actions.report.xml')
34 report_xml_ids = ir_actions_report_xml_obj.search(cr, uid, [('report_name', '=', self.name[7:])], context=context)
35- self.title = report_xml_ids and ir_actions_report_xml_obj.browse(cr,uid,report_xml_ids)[0].name or 'OpenERP Report'
36+ self.title = 'OpenERP Report'
37+ numner = 1
38+ if report_xml_ids:
39+ report = ir_actions_report_xml_obj.browse(cr, uid, report_xml_ids[0],
40+ context=context)
41+ self.title = report.name
42+ numner = report.number
43 create_doc = self.generators[report_type]
44 pdf = create_doc(rml, title=self.title)
45- return (pdf, report_type)
46+ return (pdf, report_type, self.title, number)
47
48 def create_xml(self, cr, uid, ids, datas, context=None):
49 if not context:
50
51=== modified file 'bin/report/report_sxw.py'
52--- bin/report/report_sxw.py 2010-07-16 07:34:53 +0000
53+++ bin/report/report_sxw.py 2010-08-02 08:17:44 +0000
54@@ -347,7 +347,7 @@
55 def __init__(self, *args, **argv):
56 for key,arg in argv.items():
57 setattr(self, key, arg)
58- report_xml = a(title=title, report_type=report_type, report_rml_content=rml, name=title, attachment=False, header=self.header)
59+ report_xml = a(title=title, report_type=report_type, report_rml_content=rml, name=title, attachment=False, header=self.header, number=1)
60 report_type = report_xml.report_type
61 if report_type in ['sxw','odt']:
62 fnct = self.create_source_odt
63@@ -362,7 +362,7 @@
64 fnct_ret = fnct(cr, uid, ids, data, report_xml, context)
65 if not fnct_ret:
66 return (False,False)
67- return fnct_ret
68+ return fnct_ret + (report_xml.name, report_xml.number)
69
70 def create_source_odt(self, cr, uid, ids, data, report_xml, context=None):
71 return self.create_single_odt(cr, uid, ids, data, report_xml, context or {})
72
73=== modified file 'bin/service/web_services.py'
74--- bin/service/web_services.py 2010-07-27 15:22:11 +0000
75+++ bin/service/web_services.py 2010-08-02 08:17:44 +0000
76@@ -706,13 +706,15 @@
77 import sys
78 try:
79 obj = netsvc.LocalService('report.'+object)
80- (result, format) = obj.create(cr, uid, ids, datas, context)
81+ (result, format, name, number) = obj.create(cr, uid, ids, datas, context)
82 if not result:
83 tb = sys.exc_info()
84 self._reports[id]['exception'] = ExceptionWithTraceback('RML is not available at specified location or not enough data to print!', tb)
85 self._reports[id]['result'] = result
86 self._reports[id]['format'] = format
87 self._reports[id]['state'] = True
88+ self._reports[id]['name'] = name
89+ self._reports[id]['number'] = number
90 except Exception, exception:
91
92 tb = sys.exc_info()
93@@ -748,6 +750,8 @@
94 if res2:
95 res['result'] = base64.encodestring(res2)
96 res['format'] = result['format']
97+ res['name'] = result['name']
98+ res['number'] = result['number']
99 del self._reports[report_id]
100 return res
101