Odoo Help


functional fields in openerp - convert amount to word string

on 7/14/13, 3:45 AM 648 views

I would like to know how can we convert an amount in to equivalent amount string in opnerp7. I defined a functional field to achieve this but its creating a field in my DataBase but not the data , can anyone please point out where am i wrong, I can post my sample source here


<field name="amount_words"/>

python code

function that returns converted amount -

def _amount_in_words(self, cr, uid, ids, field_name, arg, context=None):

    cur_obj = self.pool.get('res.currency')
    res = {}
    for order in self.browse(cr, uid, ids, context=context):
        taxed = untaxed = 0.0
        res[order.id] = {
            'amount_words': '0.0',
        val = val1 = 0.0
        cur = order.pricelist_id.currency_id
        for line in order.order_line:
            val1 += line.price_subtotal
            val += self._amount_line_tax(cr, uid, line, context=context)

        taxed = cur_obj.round(cr, uid, cur, val)
        untaxed = cur_obj.round(cr, uid, cur, val1)

        res[order.id]['amount_words'] = amount_to_text(float(taxed + untaxed))

    return res[order.id]['amount_words']

functional field declaration

'amount_words': fields.function(_amount_in_words, string='In Words', type="char", store=True, help="The amount in words"),

Note :- 'amount_to_text' is a my applications global function that is giving exactly what i want but i could't pass the same data in to my view ???

'amount_to_text' returns data like as follows , if i pass amount_to_text(150) it returns One Hundred and Fifty rupees Only

Any help is appreciated .... Thanks in advance

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


Odoo Training Center

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

Test it now

Question tools

1 follower(s)


Asked: 7/14/13, 3:45 AM
Seen: 648 times
Last updated: 3/16/15, 8:10 AM