İçereği Atla
Odoo Menü
  • Portal
  • Ücretsiz deneyin
  • Uygulamalar
    Finans
    • Muhasebe
    • Faturalama
    • Masraf Yönetimi
    • Elektronik Çizelge (BI)
    • Belgeler
    • İmza
    Satış
    • Müşteri İlişkileri Yönetimi (CRM)
    • Satış
    • Satış Noktası Mağaza
    • Satış Noktası Restoran
    • Abonelikler
    • Kiralama
    Web Sitesi
    • Web Sitesi Oluşturucu
    • eTicaret
    • Blog
    • Forum
    • Canlı Sohbet
    • eÖğrenme
    Tedarik Zinciri
    • Envanter
    • Üretim
    • Ürün Yaşam Döngüsü Yönetimi
    • Satın Alma
    • Bakım
    • Kalite
    İnsan Kaynakları
    • Çalışanlar
    • İşe Alım
    • İzin
    • Değerlendirme
    • Referans
    • Filo Yönetimi
    Pazarlama
    • Sosyal Medyada Pazarlama
    • E-posta ile Pazarlama
    • SMS ile Pazarlama
    • Etkinlikler
    • Pazarlama Otomasyonu
    • Anket
    Hizmetler
    • Proje Yönetimi
    • Çalışma Çizelgeleri
    • Saha Hizmeti
    • Yardım Masası
    • Planlama
    • Randevular
    Verimlilik
    • Sohbet
    • Onay
    • Nesnelerin İnterneti
    • VoIP
    • Bilgi Bankası
    • WhatsApp
    Üçüncü taraf uygulamalar Odoo Stüdyo Odoo Bulut Platformu
  • Sektörler
    Perakende satış
    • Kitapçı
    • Giyim Mağazası
    • Mobilya Mağazası
    • Gıda Marketi
    • Hırdavat Dükkanı
    • Oyuncak Dükkanı
    Gıda ve Konaklama
    • Bar ve Pub
    • Restoran
    • Fast Food Restoranı
    • Konuk Evi
    • İçecek Distribütörü
    • Otel
    Gayrimenkul
    • Emlak Acentesi
    • Mimarlık Firması
    • İnşaat
    • Emlak Yönetimi
    • Bahçe Tasarımı
    • Mülk Sahipleri Derneği
    Uzmanlık
    • Muhasebe Firması
    • Odoo Partner
    • Pazarlama Ajansı
    • Hukuk Firması
    • Yetenek Kazanımı
    • Denetim ve Belgelendirme
    Üretim
    • Tekstil
    • Metal
    • Mobilyalar
    • Gıda
    • Bira fabrikası
    • Kurumsal Hediye
    Sağlık ve Spor
    • Spor Kulübü
    • Optik Mağazası
    • Fitness Merkezi
    • Sağlıklı Yaşam Merkezi
    • Eczane
    • Kuaför Salonu
    Ticaret
    • Tamirci
    • BT Donanım & Destek
    • Güneş Enerjisi Sistemleri
    • Ayakkabı İmalatçısı
    • Temizlik Hizmetleri
    • HVAC Hizmetleri
    Diğerleri
    • Kar Amacı Gütmeyen Kuruluş
    • Çevre Ajansı
    • Reklam Panosu Kiralama
    • Fotoğrafçılık
    • Bisiklet Kiralama
    • Yazılım Bayisi
    Tüm Sektörlere Göz Atın
  • Topluluk
    Öğrenim
    • Eğitim Araçları
    • Dokümantasyon
    • Sertifikasyonlar
    • Eğitim Etkinlikleri
    • Blog
    • Podcast
    Eğitim ve Gelişim
    • Eğitim Programı
    • Scale Up! İşletme Oyunu
    • Odoo'yu Ziyaret Edin
    Yazılım
    • İndirin
    • Sürümleri Kıyaslayın
    • Sürümler
    İş Birliği
    • Github
    • Forum
    • Etkinlikler
    • Çeviriler
    • Partner Olun
    • Partnerler için Hizmetler
    • Muhasebe Firmanızı Kaydettirin
    Hizmetler
    • Partner Bulun
    • Muhasebeci Bulun
    • Bir danışmanla görüşün
    • Kurulum Hizmetleri
    • Müşteri Referansları
    • Destek
    • Sürüm Yükseltme
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Demo randevusu alın
  • Fiyatlandırma
  • Yardım

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • Müşteri İlişkileri Yönetimi
  • e-Commerce
  • Muhasebe
  • Envanter
  • PoS
  • Proje Yönetimi
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiketler (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiketler (View all)
odoo accounting v14 pos v15
About this forum
Yardım

Show warning message when enter wrong mobile no. format in Odoo 10

Abone Ol

Get notified when there's activity on this post

Bu soru işaretlendi
apipython2.7warningvalidationodoo10
5 Cevaplar
12606 Görünümler
Avatar
Pawan Kumar Sharma

Hello all,

I have a integer field 'is_mobile'. Where user entering mobile. I want that when user enter wrong mobile no. format then it show warning message "invalid no. format" and also form not save without right format. For this i applied code, but it is not work as per requirement. 

Code is below:

is_mobile = fields.Integer("Mobile")


@api.multi

    @api.constrains('is_mobile')

    def _check_phone_number(self):

        for rec in self:

            if rec.is_mobile and len(rec.is_mobile) != "^[0-9]{10}$" :

                raise ValidationError(_("Wrong value enter"))

            else:

                return False

        return {}


Thanks in advance

0
Avatar
Vazgeç
Pawan Kumar Sharma
Üretici


Avatar
Parth Patel (pat)
En İyi Yanıt

Hello Pawan,
Specific about your python condition :  

if rec.is_mobile and len(rec.is_mobile) != "^[0-9]{10}$" :
I Could not understand why you need to compare regex string with length, as it going to directly compare the string only not regex output.
So, rather you can directly do something like this :
if rec.is_mobile and len(str(rec.is_mobile)) != 10 :
1
Avatar
Vazgeç
Pawan Kumar Sharma
Üretici

Hii @Parth, Your code upto 10 digits work well, But after 10 digits it shows error "The following fields are invalid: " also warning message change into error when using character and other type words. I want that warning show else than 10 digits in any condition.

Thanks for help.

Parth Patel (pat)

Hi Pawan, The Error warning 'The following fields are invalid: ' is due to you are using is_mobile as an Integer field and it can store max 10 digits, more than that it will show error. To, avoid this you can take Char field insted.

Just sake of information :

If you are about to develope something in odoo you can even use the default phone validation module provided by odoo. Where you have to just define phone widget in xml view.

<field name="phone" widget="phone"/>

And make sure module 'phone_validation' will install. This module will validate the phone number according to the country selected.

Pawan Kumar Sharma
Üretici

Thanks parth, Now error message problem solved, but there is still one problem is that it take 10 values they might be integer, character, comma and etc. But i want only 10 integer values else validation. So, how i solve this problem for only integer 10 numbers?

Parth Patel (pat)

Hello Pawan, For that you can make use of your regex like this,

import re

pattern = re.compile("^[0-9]{10}$")

if pattern.match(string):

return true

else:

return false

Pawan Kumar Sharma
Üretici

Thanks parth work with following code:

@api.multi

@api.constrains('whats_app')

def _onchange_phone_number(self):

pattern = re.compile("^[0-9]{10}$")

for rec in self:

if pattern.match(rec.whats_app) and len(str(rec.whats_app)) == 10:

return True

else:

raise ValidationError(_("Invalid Mobile No."))

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Üye Ol
İlgili Gönderiler Cevaplar Görünümler Aktivite
"IndexError: list index out of range" on Button wizard action for sending SMS on mobile in Odoo10
api mobile python2.7 odoo10
Avatar
0
Eyl 17
4087
TypeError: unsupported operand type(s) for +: 'bool' and 'str' in Odoov10
function error api python2.7 odoo10
Avatar
Avatar
3
Eki 17
22955
How to add values of particular column from One2many field in Odoo10
api python2.7 openerp odoo10 odoo10.0
Avatar
1
Eki 17
11282
How to return action window or wizard from def copy()or def write method in odoo 10.
python2.7 odoo10
Avatar
Avatar
2
Tem 25
1670
Show edit button on odoo 10 qweb html report.
python2.7 odoo10
Avatar
0
Ara 24
1880
Topluluk
  • Eğitim Araçları
  • Dokümantasyon
  • Forum
Açık Kaynak
  • İndirin
  • Github
  • Runbot
  • Çeviriler
Hizmetler
  • Odoo.sh Hosting
  • Destek
  • Sürüm Yükseltme
  • Özel Geliştirmeler
  • Eğitim
  • Muhasebeci Bulun
  • Partner Bulun
  • Partner Olun
Hakkında
  • Şirketimiz
  • Pazarlama Gereçleri
  • İletişim
  • Kariyer
  • Etkinlikler
  • Podcast
  • Blog
  • Müşteriler
  • Hukuki • Gizlilik
  • Güvenlik
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo, müşteri ilişkileri yönetimi, eTicaret, muhasebe, envanter, satış noktası, proje yönetimi gibi şirketinizin tüm ihtiyaçlarını karşılayan bir açık kaynak işletme uygulamaları paketidir.

Odoo’nun eşsiz değer önermesi, aynı anda hem kullanımının çok kolay olup hem de tamamen entegre olmasıdır.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now