【问题标题】:Custom parser for makomako 的自定义解析器
【发布时间】:2015-11-06 01:14:25
【问题描述】:

我正在尝试声明自定义解析器,但出现错误。

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").

谁能解释一下问题出在哪里?

【问题讨论】:

    标签: parsing webkit report openerp mako


    【解决方案1】:

    试试这个:

    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")
    

    如果仍然无法正常工作,请检查报告标签(name 属性)只需与 dp.report.2 进行比较,在 .py 中我们只需要添加 report.report_name

    【讨论】:

    • 仍有问题。感谢您的回复。
    • 您可以在问题中发布报告标签吗?
    • 我想从向导生成打印。我在向导的按钮中编写了一个函数。代码是
    • 代码是:def print_report1(self, cr, uid, ids, data, context=None): if context is None: context = {} data = self.read(cr, uid, ids)[0] obj = self.pool.get('project.task').browse(cr,uid, data['task_id'][0]) flag=0 datas = { 'ids': [data['task_id'][0]], 'model': 'project.task', 'form': data } return { 'type': 'ir.actions.report.xml', 'report_name': 'dp.tally1', 'datas': datas}
    • 试试'report_name': 'dp.report.2'
    猜你喜欢
    • 2014-03-27
    • 1970-01-01
    • 2021-02-12
    • 2017-04-23
    • 2021-12-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多