mako的自定义解析器

时间:2015-08-13 07:23:10

标签: parsing webkit report openerp mako

我试图宣布自定义解析器,但我收到了错误。

NoneType' object has no attribute '__getitem__'
(<type 'exceptions.TypeError'>, TypeError("'NoneType' object has no attribute '__getitem__'",), <traceback object at 0xc336234>)".

这是我的代码:

class print_task1(report_sxw.rml_parse):
    def __init__(self, cr, uid, name, context=None):
        super(print_task1, self).__init__(cr, uid, name, context=context)

report_sxw.report_sxw('report.dp_report_2','project.task','addons/exelixir_project/report/dp_report_2_1.mako',parser=print_task1,header="purchase_rep_webk_headq").

任何人都可以解释问题是什么吗?

1 个答案:

答案 0 :(得分:0)

试试这个:

import time
from openerp.report import report_sxw

class print_task1(report_sxw.rml_parse):
    def __init__(self, cr, uid, name, context=None):
        super(print_task1, self).__init__(cr, uid, name, context)
        self.localcontext.update({
            'time': time
        })

report_sxw.report_sxw('report.dp.report.2', 
                      'project.task',
                      'addons/exelixir_project/report/dp_report_2_1.mako', 
                       parser=print_task1,
                       header=header="purchase_rep_webk_headq")

如果仍然无效,请检查报告标记(名称属性),只需与 dp.report.2进行比较在.py方面,我们只需要添加 report.report_name