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

odoo8. Reports and variables transfering

By
Keywoker
on 12/22/14, 9:39 AM 609 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.

0

zbik

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


zbik
On 1/11/15, 3:39 PM

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)

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

3 follower(s)

Stats

Asked: 12/22/14, 9:39 AM
Seen: 609 times
Last updated: 3/16/15, 8:10 AM