Browse Source

[DEL] Phone formatting modules

pull/7/head
Launchpad Translations on behalf of openerp-commiter 12 years ago
parent
commit
c07c9d3cf1
  1. 22
      crm_lead_formatted_phone/__init__.py
  2. 41
      crm_lead_formatted_phone/__openerp__.py
  3. 39
      crm_lead_formatted_phone/crm_lead_formatted_phone.py
  4. 33
      crm_lead_formatted_phone/crm_lead_formatted_phone.xml
  5. 23
      res_partner_address_formatted_phone/__init__.py
  6. 44
      res_partner_address_formatted_phone/__openerp__.py
  7. 31
      res_partner_address_formatted_phone/res_country_phone_format.py
  8. 10
      res_partner_address_formatted_phone/res_country_phone_format_data.xml
  9. 18
      res_partner_address_formatted_phone/res_country_phone_format_view.xml
  10. 41
      res_partner_address_formatted_phone/res_partner_address_formatted_phone.py
  11. 28
      res_partner_address_formatted_phone/res_partner_address_formatted_phone.xml

22
crm_lead_formatted_phone/__init__.py

@ -1,22 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2012 Savoir-faire Linux (<http://www.savoirfairelinux.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import crm_lead_formatted_phone

41
crm_lead_formatted_phone/__openerp__.py

@ -1,41 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2012 Savoir-faire Linux (<http://www.savoirfairelinux.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
"name" : "Format phone numbers of lead ",
"version" : "0.1",
"author" : "Savoir-faire Linux",
"website" : "http://www.savoirfairelinux.com",
"license" : "AGPL-3",
"category" : "CRM",
"description" : """
This module formats the lead phone numbers based on the country phone format.
""",
"images" : [],
"depends" : ["crm", "res_partner_address_formatted_phone"],
"demo" : [],
"test" : [],
"data" : [
"crm_lead_formatted_phone.xml",
],
"installable": True,
"complexity": "easy",
}

39
crm_lead_formatted_phone/crm_lead_formatted_phone.py

@ -1,39 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2012 Savoir-faire Linux (<http://www.savoirfairelinux.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import re
from osv import fields, osv
class crm_lead_formatted_phone(osv.osv):
_inherit = 'crm.lead'
def on_change_phone(self, cr, uid, ids, field_name, phone, country_id=False):
result = phone
if phone:
digits = [c for c in phone if c.isdigit()]
if len(digits) >= 10:
result = u"(%s) %s-%s" % ("".join(digits[0:3]), "".join(digits[3:6]),
"".join(digits[6:10]))
if len(digits) > 10:
result += " x %s" % "".join(digits[10:])
return { 'value': { field_name: result } }
crm_lead_formatted_phone()

33
crm_lead_formatted_phone/crm_lead_formatted_phone.xml

@ -1,33 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record model="ir.ui.view" id="crm_lead_formatted_phone_form">
<field name="name">crm.lead.formatted.phone.form</field>
<field name="model">crm.lead</field>
<field name="inherit_id" ref="crm.crm_case_form_view_leads"/>
<field name="type">form</field>
<field name="arch" type="xml">
<data>
<xpath expr="//notebook/page[@string='Lead']/group/field[@name='phone']"
position="replace">
<field name="phone" on_change="on_change_phone('phone', phone, country_id)"/>
</xpath>
<xpath expr="//notebook/page[@string='Lead']/group/field[@name='mobile']"
position="replace">
<field name="mobile" on_change="on_change_phone('mobile', mobile, country_id)"/>
</xpath>
<xpath expr="//notebook/page[@string='Lead']/group/field[@name='fax']"
position="replace">
<field name="fax" on_change="on_change_phone('fax', fax, country_id)"/>
</xpath>
</data>
</field>
</record>
</data>
</openerp>

23
res_partner_address_formatted_phone/__init__.py

@ -1,23 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2012 Savoir-faire Linux (<http://www.savoirfairelinux.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import res_partner_address_formatted_phone
import res_country_phone_format

44
res_partner_address_formatted_phone/__openerp__.py

@ -1,44 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2012 Savoir-faire Linux (<http://www.savoirfairelinux.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
"name" : "Format phone numbers of partner",
"version" : "0.1",
"author" : "Savoir-faire Linux",
"website" : "http://www.savoirfairelinux.com",
"license" : "AGPL-3",
"category" : "Partner",
"description" : """
This module formats the partner phone numbers based on the format of the
phonenumbers library (http://pypi.python.org/pypi/phonenumbers).
""",
"images" : [],
"depends" : ["base"],
"demo" : [],
"test" : [],
"data" : [
"res_partner_address_formatted_phone.xml",
"res_country_phone_format_view.xml",
"res_country_phone_format_data.xml",
],
"installable": True,
"complexity": "easy",
}

31
res_partner_address_formatted_phone/res_country_phone_format.py

@ -1,31 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2012 Savoir-faire Linux (<http://www.savoirfairelinux.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import re
from osv import fields, osv
class res_country_phone_format(osv.osv):
_inherit = 'res.country'
_columns = {
'phone_format': fields.char('Phone Format', size=100)
}
res_country_phone_format()

10
res_partner_address_formatted_phone/res_country_phone_format_data.xml

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<record model="res.country" id="base.ca">
<field name="phone_format">(XXX) XXX-XXXX x XXX</field>
</record>
</data>
</openerp>

18
res_partner_address_formatted_phone/res_country_phone_format_view.xml

@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record model="ir.ui.view" id="view_res_country_phone_format_form">
<field name="name">res.country.phone.format.form</field>
<field name="model">res.country</field>
<field name="inherit_id" ref="base.view_country_form"/>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="address_format" position="after">
<field name="phone_format"/>
</field>
</field>
</record>
</data>
</openerp>

41
res_partner_address_formatted_phone/res_partner_address_formatted_phone.py

@ -1,41 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2012 Savoir-faire Linux (<http://www.savoirfairelinux.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import re
from osv import fields, osv
class res_partner_address_formatted_phone(osv.osv):
_inherit = 'res.partner.address'
def on_change_phone(self, cr, uid, ids, field_name, phone, country_id=False):
result = phone
phone_format = self.pool.get('phone_format')
if phone:
digits = [c for c in phone if c.isdigit()]
crosses = [x for x in phone_format if c == 'X']
if len(digits) >= len(crosses):
result = u"(%s) %s-%s" % ("".join(digits[0:3]), "".join(digits[3:6]),
"".join(digits[6:10]))
if len(digits) > 10:
result += " x %s" % "".join(digits[10:])
return { 'value': { field_name: result } }
res_partner_address_formatted_phone()

28
res_partner_address_formatted_phone/res_partner_address_formatted_phone.xml

@ -1,28 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record model="ir.ui.view"
id="view_customer_american_phone_formatter_form">
<field name="name">res.partner.american_phone_formatter.form</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form" />
<field name="type">form</field>
<field name="arch" type="xml">
<data>
<xpath expr="//notebook/page[@string='General']/field/form//group/field[@name='phone']"
position="replace">
<field name="phone" on_change="on_change_phone('phone', phone, country_id)" />
</xpath>
<xpath expr="//notebook/page[@string='General']/field/form//group/field[@name='mobile']"
position="replace">
<field name="mobile" on_change="on_change_phone('mobile', mobile, country_id)" />
</xpath>
<xpath expr="//notebook/page[@string='General']/field/form//group/field[@name='fax']"
position="replace">
<field name="fax" on_change="on_change_phone('fax', fax, country_id)" />
</xpath>
</data>
</field>
</record>
</data>
</openerp>
Loading…
Cancel
Save