Skip to Content
Menu
This question has been flagged
1 Reply
2579 Views

hi everyone.

I'm making a report in Odoo 8 and my htm file has such code lines:

<TD CLASS="R37C4"><SPAN STYLE="white-space:nowrap;">${line.price_unit or ''}</SPAN></TD>

it works and I get my pdf after compilation. But, I can get acces only to the "sale.order" model and dependencies. But i need to get the access to another model, stock.quant. There is no dependency between these models. How can I get it? Thank you.

Avatar
Discard
Best Answer

You create report parser like this (see method currency_text):

<span t-if="o.currency_id" t-esc="currency_text(o.amount_total, o.currency_id.name, o.partner_id.lang or 'pl_PL')"/>

class report_invoice(models.AbstractModel):
    _name = 'report.account.report_invoice'
    _template = 'account__pl.report_invoice_pl'

    def currency_text(self, sum, currency, language):
        return currency_to_text(sum, currency, language)

    @api.multi
    def render_html(self, data=None):
                                                                     
        report_obj = self.env['report']
        report = report_obj._get_report_from_name(self._template)        
       
        docargs = {
            'currency_text': self.currency_text,        
            'doc_ids': self._ids,
            'doc_model': report.model,
            'docs': self,
        }

        return report_obj.render(self._template, docargs)

Avatar
Discard