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
View:
<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