python-2.7odooopenerp-8odoo-9

Total amount in words in qweb report odoo


I want to get total amount of purchase order in words on qweb report. Someone please tell me what is the process to get it or what code i can do... i'll be very thankful...


Solution

  • Create a function in your purshase.order model that converts total_amount to letters.

    from openerp import models, api
    from openerp.tools import amount_to_text_en
    
    class purchase_order(models.Model):
        _inherit = 'purchase.order'
    
        @api.depends('amount_total', 'currency_id')
        def compute_text(self):
            return amount_to_text_en.amount_to_text(self.amount_total, self.currency_id.symbol)
    

    To call it from QWEB reports use:

    <span t-esc="o.compute_text()" />