Skip to content
Snippets Groups Projects
Commit 45fdd0b0 authored by Fabien Pinckaers's avatar Fabien Pinckaers Committed by Thibault Delavallée
Browse files

[ADD] crm_phone_validation: implement phone validation in crm

This bridge module adds phone / fax / mobile number validation for lead
and partner models, using the recently-introduced phone validation tool
module.

This is done at onchange level and is therefore not blocking or
computationally heavy. Its main use is to help salesmen correctly
entering or checking phone numbers when using Odoo.
parent 96a00471
No related branches found
No related tags found
No related merge requests found
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import models
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
{
'name': 'Crm Phone Numbers Validation',
'summary': 'Validate and format phone numbers for leads and contacts',
'sequence': '9999',
'category': 'Hidden',
'description': """
CRM Phone Numbers Validation
============================
This module allows for validate and format phone numbers for leads and contacts.""",
'data': [
],
'depends': [
'phone_validation',
'crm',
],
}
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import res_partner
from . import crm_lead
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, models
class Lead(models.Model):
_name = 'crm.lead'
_inherit = ['crm.lead', 'phone.validation.mixin']
@api.onchange('phone', 'country_id')
def _onchange_phone_validation(self):
if self.phone:
self.phone = self.phone_format(self.phone)
@api.onchange('mobile', 'country_id')
def _onchange_mobile_validation(self):
if self.mobile:
self.mobile = self.phone_format(self.mobile)
@api.onchange('fax', 'country_id')
def _onchange_fax_validation(self):
if self.fax:
self.fax = self.phone_format(self.fax)
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, models
class Contact(models.Model):
_name = 'res.partner'
_inherit = ['res.partner', 'phone.validation.mixin']
@api.onchange('phone', 'country_id')
def _onchange_phone_validation(self):
if self.phone:
self.phone = self.phone_format(self.phone)
@api.onchange('mobile', 'country_id')
def _onchange_mobile_validation(self):
if self.mobile:
self.mobile = self.phone_format(self.mobile)
@api.onchange('fax', 'country_id')
def _onchange_fax_validation(self):
if self.fax:
self.fax = self.phone_format(self.fax)
......@@ -15,7 +15,7 @@ odoo.define('website_crm.tour', function(require) {
}, {
content: "Complete phone number",
trigger: "input[name=phone]",
run: "text 118.218"
run: "text +32 485 118.218"
}, {
content: "Complete Email",
trigger: "input[name=email_from]",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment