Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
6822 มุมมอง

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

อวตาร
ละทิ้ง