Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

'Object has no attribute' in custom report function

By
Aitor Bouzas
on 12/26/14, 7:24 AM 526 views

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.

0
Aitor Bouzas
On 12/26/14, 10:03 AM

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

0

Atchuthan - Technical Consultant, Sodexis Inc

--Atchuthan - Technical Consultant, Sodexis Inc--
3883
| 5 3 8
Puducherry, India
--Atchuthan - Technical Consultant, Sodexis Inc--
Passionate coder in Python/Odoo(formerly known as OpenERP).

Contact me via GMail: atchuthantu@gmail.com via Skype: atchuthan_skype
via Linkedin: http://in.linkedin.com/in/atchuthantu
Atchuthan - Technical Consultant, Sodexis Inc
On 12/26/14, 8:17 AM

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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 12/26/14, 7:24 AM
Seen: 526 times
Last updated: 3/16/15, 8:10 AM