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

How we inherit invoice report to change the attachment attribute on Odoo v8

By
tansadio
on 12/5/14, 10:26 AM 1,310 views

<openerp>
 <data>
     <report
         id="account_invoices"
         model="account.invoice"
         string="Invoices"
         report_type="qweb-pdf"
         name="account.report_invoice"  
         file="account.report_invoice"  
         attachment_use="True"

         attachment="(object.state in ('open','paid')) and ((object.number or '').replace('/','')+'.pdf')"

        />
 </data>
</openerp>

 

I need your HELP.

Thanks for advances

0

zbik

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


zbik
On 12/5/14, 10:54 AM

I use in my module "account__pl":

<report
            id="account_invoices__pl"
            model="account.invoice"
            string="Invoices PL"
            report_type="qweb-pdf"
            name="account__pl.report_invoice_pl"
            file="account__pl.report_invoice_pl"
            attachment_use="True"
            attachment="(object.state in ('open','paid')) and ('IPL'+(object.number or '').replace('/','')+'.pdf')"
            multi="True"
        />

 

and in report_invoice_pl.py:

 

class report_invoice_pl(osv.AbstractModel):
    _name = 'report.account.report_invoice'
    _inherit = 'report.abstract_report'
    _template = 'account__pl.report_invoice_pl'
    _wrapped_report_class = parse_invoice_pl 

 

or, in new style reports:

 

class report_invoice(models.AbstractModel):
    _name = 'report.account.report_invoice'
    _template = 'account__pl.report_invoice_pl'
    
    @api.multi
    def render_html(self, data=None):
                                                                     
        report_obj = self.env['report']
        report = report_obj._get_report_from_name(self._template)        
       
        docargs = {
            'doc_ids': self._ids,
            'doc_model': report.model,
            'docs': self,
        }

        return report_obj.render(self._template, docargs)

class report_invoice_pl(report_invoice):
    _name = 'report.account__pl.report_invoice_pl'

 

 

0
tansadio
On 12/5/14, 1:15 PM

 

and in report_invoice_pl.py:

 

class report_invoice_pl(osv.AbstractModel):
    _name = 'report.account.report_invoice'
    _inherit = 'report.abstract_report'
    _template = 'account__pl.report_invoice_pl'
    _wrapped_report_class = parse_invoice_pl 

This Model used to embed old style reports

ok, you're right, improve in yourself

zbik
on 12/5/14, 1:49 PM

did you check if it works?

tansadio
on 12/5/14, 1:52 PM

did you check if it works?

tansadio
on 12/5/14, 1:52 PM

thanks for your reply!!!

tansadio
on 12/5/14, 2:03 PM

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/5/14, 10:26 AM
Seen: 1310 times
Last updated: 3/16/15, 8:10 AM