在向导的报告中打印参数

时间:2015-11-22 07:30:31

标签: python openerp odoo-8 formwizard qweb

我正在尝试从向导中获取报告,我指的是mi res_model:stock.quant来自我的回复:

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',
}   

我正在获取正确的模型和报告,但是当我尝试使用某个字段时,我收到此错误:

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

如果我尝试使用模型中的某个函数,我会收到此错误:

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

就像我在另一个没有字段和函数的模型中那样命名为la that.but if a do

<span t-esc="o"/>

在报告中

y get: stock.quant(42,)

所以问题是,如何从回报中获取和使用参数。

我认为我是在正确的对象中,我以传统方式构建此报告及其单词但通过返回调用函数我没有通过参数。

1 个答案:

答案 0 :(得分:1)

您的数据是字典,只有两个值 要做到如上所述,试试这个:

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',
    }
相关问题