Odoo Help

3

0
3 Answers
0
Avatar

Semah Raddaoui Tunisia

--Semah Raddaoui--

908
| 5 3 9
Gafsa, Tunisia
--Semah Raddaoui--
Semah Raddaoui Tunisia
11/23/13, 5:53 AM

Hi Pavel,

To convert amount to text, you can use the amount_to_text method defined in openerp/tools/amount_to_text_en.py

Create a field which will store text value of amount. You can either create char or text field.

 'text_amount': fields.char("TextAmount", size=100)

or

'text_amount': fields.text("Text Amount")

Now write a on_change method which will be called when you change the value of amount field. First add on_change in your xml where your amount field is.

Like this:

<field name="your_amount_field" on_change="onchange_amount(your_amount_field)"/>

Write the following code inside your class in your py:

from openerp.tools import amount_to_text_en

def onchange_amount(self, cr, uid, ids, amount):
    text_amount = amount_to_text_en.amount_to_text(amount, 'en', 'EURO')
    return {'value': {'text_amount': text_amount}}

This solution is suggested by Sudhir Arya

0
Pavel Pavlov Bulgaria
11/22/13, 3:40 AM

Still haven't found any solution, so any help is appreciated. Thank you!

0
Ajay India
11/22/13, 9:06 AM

Hi Pavel, You should not define on_change on function field, it will not be called. For your scenario you should override the function which is called to count 'amount_total'. Want to add one more thing the value fetched from on_change can't be saved b'coz you have field with readonly attributes. Values with readonly attribute didn't get in vals on 'write' method.

Thanks, Ajay Chauhan

Ask a Question
Writer
Keep Informed
1 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