Odoo Help

1

1
2 Answers
3
Avatar

Sajin Aziz

--Sajin Aziz--

798
| 2 2 5
Dubai, United Arab Emirates
--Sajin Aziz--
Sajin Aziz
3/2/15 06:23

if it is in the same model then you can use  <span t-esc="o.call_function1(o.amount_total)" />

2 Comments
ePillars Systems LLC, Shawn Varghese
5/2/15 04:25

Thanks Sajin. I am extending the quotation report, so the model is 'sale.order'. Does that mean that I have to define call_function1() inside 'class sale_order'?

GLOBAL CREATIVE CONCEPTS TECH CO LTD (iWesabe)
26/1/19 00:33

Yes

2
Avatar

Zbik

--Zbik--
10913
| 7 6 9
Łódź, Poland
--Zbik--


Zbik
3/2/15 03:47

You have to create your own 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)

2 Comments
ePillars Systems LLC, Shawn Varghese
5/2/15 04:20

Thanks zbik. I will try this out and get back.

Sameer Ahmad
15/4/19 01:43

Hi,

Can someone tell me what does t-if="o.currency_id" do in the above code and also the def currency_text is returning some values so where and how is the above code receiving them in QWEB report for a later access?

Ask a Question
Writer
Keep Informed
2 follower(s)
About This Community

This platform 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.

Register
Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now