jasper_reports: Get model and Id without data
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
openobject-jasper-reports |
New
|
Undecided
|
Unassigned |
Bug Description
In point_of_sale, we replace rml report default to jrxml.
When click button print, we need to print account.invoice report, but when execute jasper_reports, in data is null
[2012-01-18 20:06:49,
[2012-01-18 20:06:49,
[2012-01-18 20:06:49,
[2012-01-18 20:06:49,
[2012-01-18 20:06:49,
[2012-01-18 20:06:49,
[2012-01-18 20:06:49,
[2012-01-18 20:06:49,
But in context, we have model and id. We can get this information if data is null
Here patch:
--- jasper_report.py (revision 713)
+++ jasper_report.py (working copy)
@@ -248,6 +248,9 @@
# an empty 'records' parameter while still executing using 'records'
data[
data[
+ if not 'model' in data and 'active_model' in context:
+ data['model'] = context[
+ data['id'] = context[
r = Report( name, cr, uid, ids, data, context )
#return ( r.execute(), 'pdf' )
return r.execute()
Here all class create:
def create(self, cr, uid, ids, data, context):
name = self.name
if self.parser:
d = self.parser( cr, uid, ids, data, context )
ids = d.get( 'ids', ids )
name = d.get( 'name', self.name )
# Use model defined in report_jasper definition. Necesary for menu entries.
data['model'] = d.get( 'model', self.model )
data['records'] = d.get( 'records', [] )
# data_source can be 'model' or 'records' and lets parser to return
# an empty 'records' parameter while still executing using 'records'
data[
data[
if not 'model' in data and 'active_model' in context:
data['model'] = context[
data['id'] = context[
r = Report( name, cr, uid, ids, data, context )
#return ( r.execute(), 'pdf' )
return r.execute()
Feedback?
affects: | openobject-client-kde → openobject-jasper-reports |
or more better:
--- jasper_report.py (revision 713) 'data_source' ] = d.get( 'data_source', 'model' ) 'parameters' ] = d.get( 'parameters', {} ) 'model' ,False) and context. get('active_ model', False): 'active_ model'] 'active_ id']
+++ jasper_report.py (working copy)
@@ -248,6 +248,9 @@
# an empty 'records' parameter while still executing using 'records'
data[
data[
+ if not data.get(
+ data['model'] = context[
+ data['id'] = context[
r = Report( name, cr, uid, ids, data, context )
#return ( r.execute(), 'pdf' )
return r.execute()