跳至內容
選單
此問題已被標幟
2 回覆
6797 瀏覽次數

Hi everyone,

I don't know why this error is showing up. I'm trying to add a custom report with a function this way:

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

    def prueba(self):
        return 'A'

And as I press "Print" it just says:

sale_recurring_orders_agreement' object has no attribute 'prueba'

(<type 'exceptions.AttributeError'>, AttributeError("'sale_recurring_orders_agreement' object has no attribute 'prueba'",), <traceback object at 0x03CB1E40>)

Can someone help me?

Thank you very much for your support.

頭像
捨棄
最佳答案

In RML or MAKO file of your report. The function "prueba2" would have called from it.

EDIT:

Try this in your new module.

from openerp.addons.purchase_requisition.report.requisition import requisition
if Service._services.has_key('report.purchase.requisition'):     # Removing existing report definition
    del Service._services['report.purchase.requisition']

class sale_recurring_orders_agreement(requisition):             # Inheriting original print parser class
    def __init__(self, cr, uid, name, context=None):
        super(sale_recurring_orders_agreement, self).__init__(cr, uid, name, context=context)
        self.localcontext.update({
            'time': time,
            'prueba': self.prueba,
        })

    def prueba(self):
        return 'A'

report_sxw.report_sxw('report.purchase.requisition', 'purchase.requisition', 'addons/purchase_requisition/report/purchase_requisition.rml', parser=sale_recurring_orders_agreement)
                                 # add print definition with new print parser

頭像
捨棄
作者 最佳答案

Hi atchuthan,

I just edited the post because the error is in "prueba" without the "2". The error is showing up without calling the function, it shows up as I place that code into the python file...

EDIT:

I JUST SOLVED IT, it was a problem with tabulation and spaces...

頭像
捨棄