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

Qweb report

By
Umashankar Subramani
on 1/20/15, 8:28 AM 964 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)

0

zbik

--zbik--
5941
| 6 4 7
Lodz, Poland
--zbik--


zbik
On 1/20/15, 8:42 AM

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)

 

Its not working still i got that error

Umashankar Subramani
on 1/20/15, 8:50 AM

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

zbik
on 1/20/15, 9:02 AM

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

Umashankar Subramani
on 1/20/15, 9:06 AM

I have given that too....

Umashankar Subramani
on 1/20/15, 9:06 AM

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

zbik
on 1/20/15, 9:12 AM

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)

Umashankar Subramani
on 1/20/15, 9:14 AM

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

zbik
on 1/20/15, 9:19 AM

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

zbik
on 1/20/15, 9:21 AM

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

Umashankar Subramani
on 1/21/15, 12:06 AM

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]

Umashankar Subramani
on 1/21/15, 2:38 AM

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: 1/20/15, 8:28 AM
Seen: 964 times
Last updated: 3/16/15, 8:10 AM