Odoo Help

0

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

By
John Baldwin
on 12/30/14, 1:46 AM 699 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.

 

1

Akhil P Sivan

--Akhil P Sivan--
3930
| 5 3 7
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.

0

Ludo - Neobis

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

Developer

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.

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

Question tools

1 follower(s)

Stats

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