REPORTS

Reports

Report actions are managed by the model `*ir.action.report* <http://hg.tryton.org/trytond/file/3.2/trytond/ir/action.py#l364>`_.


Reports on sales

First you need to get the information which reports are available on the model *sale.sale*::

{

"id": 2,
"method":"model.ir.action.report.search_read",
"params":[

userid,
sessionid,
[('active', '=', True), ('model', '=', 'sale.sale')],
0,
None,
[('report_name', 'ASC')],
['id', 'action.name', report_name'],
context # Replace this with a full context

]

}

This is an example of the return value of this request::

{

"id": 2,
"result": [

{

"action.name": "Verkauf", # This is a human readable translated name of the report
"id": 253, # This is the id of the report action
"report_name": "sale.sale" # This is the unique internal name of the report

}

]

}


Then you need to execute the report::

{

"id": 2,
"method":"report.sale.sale.execute",
"params":[

userid,
sessionid,
[5], # This is the id of the sale you want to execute the report for
{

'model': 'sale.sale', # This is the model on which the report is executed
'ids': [5], # This is a list of ids the report should be executed for.
# Most of the time it is identical to the value of 'id'
'id': 5, # This is a single id of model *sale.sale* the report should be executed for
'action_id': 253 # This is the id of the report action that should be executed

},
context # Replace this with a full context

]

}

This is an example of a return value of this request::

{

"id": 2,
"result": [

"odt", # This is the file type extension of the report
{

"base64": "UEsDBBQAAAAAAGxAg0q31TR..........FBgAAAAASABIAvwQAAP1eCgAAAA==\n", # base64 encoded report content
"__class__": "buffer"

},
false, # If true this means the report should be printed directly to a printer except of displaying it
"Verkauf" # The human readable name of the report action

]

}