pythonodooodoo-8formwizardqweb

Print params in report from a wizard


I'm trying to get a report from wizard, I'm pointing to mi res_model:stock.quant from my return:

def print_report(self, cr, uid, ids, context=None):
datas = {'partner' : context.get('cliente'), 'mounth':context.get('mes')}
return {
    'type': 'ir.actions.report.xml',
    #~ 'report_file': 'stock.uas.wizard',
    'report_name': 'stock.report_uas_document',
    'report_type': 'qweb-html',
    'datas': datas,
    'context': context,
    'res_model': 'stock.quant',
    'src_model': 'stock.quant',
}   

I'm fetching the right model and report, but when y try to consume some field I get this error:

QWebException: "'NoneType' object has no attribute 'get_pallets'" while evaluating

And if I try with some function inside the model I get this error:

QWebException: ('MissingError', you'One of the documents you are trying to access has been deleted, please try again after refreshing.')

Like I am in another model with no field and function named la that.but if a do

<span t-esc="o"/>

In the report

y get: stock.quant(42,)

So the question is, how can I get and consume param from a return.

I think I am in the right object, I build this report in traditional way and its word but through a return call function I don't get pass the param.


Solution

  • Your datas is a dictionary and has only two values.
    To do as explained above, try this:

    def print_report(self, cr, uid, ids, context=None):
        assert len(ids) == 1,
        datas = {
            'ids': ids,
            'model': 'stock.quant',
            'form': self.read(cr, uid, ids[0], context=context)
        }
        return {
            'type': 'ir.actions.report.xml',
            #~ 'report_file': 'stock.uas.wizard',
            'report_name': 'stock.report_uas_document',
            'report_type': 'qweb-html',
            'datas': datas,
            'context': context,
            'res_model': 'stock.quant',
            'src_model': 'stock.quant',
        }