This question has been flagged
1 Reply
4321 Views

I tried to generate the report for suppliers using Qweb, i got some error please anyone give some ideas how to rectify this error......

class ParticularReport(models.AbstractModel):
    _name = 'report.b_supplier_report.report_supplier'
    @api.multi
    def render_html(self,cr,uid,ids, data=None,context=None):
        report_obj = self.env['report']
        report = report_obj._get_report_from_name(cr,uid,'b_supplier_report.report_supplier')
        ids1=self.pool.get("res.partner").search(cr,uid,['supplier','=',True])
        docargs = {
            'doc_ids': ids1,
            'doc_model': report.model,
            'docs': self.env[report.model].browsebrowse(
                cr, uid, ids, context=context),
        }
        return report_obj.render(cr,uid,'b_supplier_report.report_supplier', docargs,context=context)

TypeError: render_html() takes at least 4 arguments (2 given)

Avatar
Discard
Best Answer

This is the formula:

from openerp import api, models

class ParticularReport(models.AbstractModel):
    _name = 'report.<<your_module.reportname>>'
    @api.multi
    def render_html(self, data=None):
        report_obj = self.env['report']
        report = report_obj._get_report_from_name('<<your_module.reportname>>')
        docargs = {
            'doc_ids': self._ids,
            'doc_model': report.model,
            'docs': self,
        }
        return report_obj.render('<<your_module.reportname>>', docargs)

 

Avatar
Discard
Author

Its not working still i got that error

You have... from openerp import api, models ...? Edit your question and show what you have now.

Author

It is giving the same error TypeError: render_html() takes at least 2 arguments (2 given)

Author

I have given that too....

Error is different ... least 2 arguments ... not ... least 4 arguments... as previously! Show code.

Author

Ya , but when i use def render_html(self, cr, uid, ids, data=None, context=None): report_obj = self.env['report'] report = report_obj._get_report_from_name(cr,uid,'b_supplier_report.report_supplier') ids1=self.pool.get("res.partner").search(cr,uid,['supplier','=',True]) rec1= self.pool.get('res.partner').browse(cr,uid,ids1,context=context) docargs = { 'doc_ids': rec1, 'doc_model': report.model, 'docs': self.pool[report.model].browse( cr, uid, ids, context=context), } return report_obj.render(self,cr,uid,'b_supplier_report.report_supplier', docargs,context=context) Error is TypeError: render_html() takes at least 4 arguments (2 given)

Why ... report_obj.render(self,cr,uid,'b_supplier_report.report_supplier', docargs,context=context)...... do according to the pattern!

Other code, according to the api@multi, too!

Author

I have tried both it doesn't work, what is the problem with that code, when this type of error will occur

Author

I got the output zbik thanks for your discussion...... Error is while selecting the supplier in the context i just missed to given inside the tuple that cause this error, ids1=self.pool.get("res.partner").search(cr,uid,[('supplier','=',True)]) instead i used ['supplier','=',True]