Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
6788 Widoki

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.

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Autor Najlepsza odpowiedź

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

Awatar
Odrzuć