Odoo Help


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


Can a computed field be used to change it's own value on the fly for Phone Number Formatting?

John Baldwin
on 12/30/14, 1:46 AM 576 views

Fairly new to python but learning and could use some experience here. I want to  use python-phonenumbers class 'AsYouTypeFormatter' found here: https://github.com/daviddrysdale/python-phonenumbers/blob/dev/python/phonenumbers/asyoutypeformatter.py to format phone numbers into (xxx) xxx-xxxx US format as the user enters them. Can somebody please tell me if this is possible and maybe where to begin.

Formatting phone numbers in Odoo seems to be a nightmare. I found a few modules but they make the numbers clickable for telephony, I just want properly formatted numbers in the DB.

Thanks in advance for any help.



Akhil P Sivan

--Akhil P Sivan--
| 5 3 6
Kochi, India
--Akhil P Sivan--

Interested in exploring Odoo both technically & functionality wise.

email-id : akhilpsivan01@gmail.com

Akhil P Sivan
On 12/30/14, 2:21 AM

Yes, its possible. I think the requirement is to be done in odoo 8 right? Then you can create a compute field, which calls the function to format value in required format. For that compute function, the link you have given can be used. I can help you doing that or to create a custom module for you. Please contact for any queries: baijuks@hotmail.com, akhil.p.sivan007@gmail.com.


Ludo - Neobis

--Ludo - Neobis--
| 2 2 5
Hoogvliet, Netherlands
--Ludo - Neobis--


Ludo - Neobis
On 12/30/14, 2:27 AM

The only struggle I think you will find is the "asyoutype" part. Odoo basically only serves state-based web-pages, so for these things you will likely resort to javascript.

Make sure that the code is accessable using import like any standard library (look up python path). Next up, make sure the formatted number is stored as something Odoo will still accept. If you want formatting and/or symbols other than number, you should likely create a char or text field on the partner. If I recall correctly, in Odoo the phone number field already is such a field.

I think your best bet would be to check out other javascript code in the modules to see how Odoo handles input character by character, as that essentially is what you need.

Alternatively (and much easier) you could create an on_change method for the field. Then, if someone is finished typing in all the digits and skips to the next field, the number will be validated, formatted and returned to the field. Like an auto_correct functionality. On_change is default in Odoo.

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 community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)


Asked: 12/30/14, 1:46 AM
Seen: 576 times
Last updated: 3/16/15, 8:10 AM