Browse Source

[MIG] Migrated base_phone to v10.0 (#107)

[MIG] Migrated base_phone to v10.0

* Define Phone and Fax as real field types, to avoid the need of defining the widget on each view

* [IMP] Add missing ImportError checks for the phonenumbers module
pull/110/merge
Sylvain Garancher 8 years ago
committed by Pedro M. Baeza
parent
commit
e81c7b46d5
  1. 4
      .travis.yml
  2. 2
      base_phone/README.rst
  3. 1
      base_phone/__init__.py
  4. 4
      base_phone/__manifest__.py
  5. 3
      base_phone/controllers/__init__.py
  6. 8
      base_phone/controllers/main.py
  7. 28
      base_phone/fields.py
  8. 1
      base_phone/models/__init__.py
  9. 14
      base_phone/models/phone_common.py
  10. 13
      base_phone/models/res_company.py
  11. 6
      base_phone/models/res_partner.py
  12. 14
      base_phone/security/phone_security.xml
  13. 155
      base_phone/static/src/js/phone_widget.js
  14. 12
      base_phone/static/src/xml/phone.xml
  15. 1
      base_phone/tests/test_phone.py
  16. 33
      base_phone/views/res_company_view.xml
  17. 30
      base_phone/views/res_partner_view.xml
  18. 54
      base_phone/views/res_users_view.xml
  19. 18
      base_phone/web_phone.xml
  20. 46
      base_phone/wizard/number_not_found.py
  21. 80
      base_phone/wizard/number_not_found_view.xml
  22. 2
      base_phone/wizard/reformat_all_phonenumbers.py
  23. 80
      base_phone/wizard/reformat_all_phonenumbers_view.xml

4
.travis.yml

@ -32,10 +32,6 @@ install:
- export PATH=${HOME}/maintainer-quality-tools/travis:${PATH}
- travis_install_nightly
- pip install phonenumbers py-Asterisk SOAPpy
- hg clone http://bitbucket.org/anybox/web_action_request -b ${VERSION} ${HOME}/web_action_request
- if [ -d /home/travis/${ODOO_REPO##*/}-${VERSION}/addons ]; then ln -s ${HOME}/web_action_request/web_action_request /home/travis/${ODOO_REPO##*/}-${VERSION}/addons; fi
- hg clone http://bitbucket.org/anybox/bus_enhanced -b ${VERSION} ${HOME}/bus_enhanced
- if [ -d /home/travis/${ODOO_REPO##*/}-${VERSION}/addons ]; then ln -s ${HOME}/bus_enhanced/bus_enhanced /home/travis/${ODOO_REPO##*/}-${VERSION}/addons; fi
script:
- travis_run_tests

2
base_phone/README.rst

@ -54,7 +54,7 @@ There is no specific usage procedure for this module.
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/{repo_id}/9.0
:target: https://runbot.odoo-community.org/runbot/228/10.0
Known issues / Roadmap
======================

1
base_phone/__init__.py

@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from . import fields
from . import controllers
from . import models
from . import wizard

4
base_phone/__manifest__.py

@ -22,7 +22,7 @@
{
'name': 'Base Phone',
'version': '9.0.0.1.0',
'version': '10.0.0.1.0',
'category': 'Phone',
'license': 'AGPL-3',
'summary': 'Validate phone numbers',
@ -42,5 +42,5 @@
],
'qweb': ['static/src/xml/*.xml'],
'images': [],
'installable': False,
'installable': True,
}

3
base_phone/controllers/__init__.py

@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import main

8
base_phone/models/controller.py → base_phone/controllers/main.py

@ -19,13 +19,11 @@
#
##############################################################################
import openerp
import odoo
class BasePhoneController(openerp.addons.web.http.Controller):
_cp_path = '/base_phone'
@openerp.addons.web.http.jsonrequest
class BasePhoneController(odoo.http.Controller):
@odoo.http.route('/base_phone', type='json', auth='none')
def click2dial(self, req, phone_number, click2dial_model, click2dial_id):
res = req.session.model('phone.common').click2dial(
phone_number, {

28
base_phone/fields.py

@ -5,15 +5,19 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp import api, fields, models
from odoo import api, fields, models
from operator import attrgetter
import phonenumbers
import logging
_logger = logging.getLogger(__name__)
try:
import phonenumbers
except ImportError:
_logger.debug('Cannot `import phonenumbers`.')
class Phone(fields.Char):
class Fax(fields.Char):
type = 'fax'
_slots = {
'country_field': None,
@ -21,9 +25,9 @@ class Phone(fields.Char):
}
def __init__(
self, string=None, country_field=None, partner_field=None,
**kwargs):
super(Phone, self).__init__(
self, string=fields.Default, country_field=fields.Default,
partner_field=fields.Default, **kwargs):
super(Fax, self).__init__(
string=string, country_field=country_field,
partner_field=partner_field, **kwargs)
@ -31,13 +35,13 @@ class Phone(fields.Char):
_related_partner_field = property(attrgetter('partner_field'))
def _setup_regular_full(self, model):
super(Phone, self)._setup_regular_full(model)
super(Fax, self)._setup_regular_full(model)
assert self.country_field in model._fields or \
self.partner_field in model._fields, \
"field %s with unknown country_field and partner_field" % self
def convert_to_cache(self, value, record, validate=True):
res = super(Phone, self).convert_to_cache(
res = super(Fax, self).convert_to_cache(
value, record, validate=validate)
# print 'db value', res
if res:
@ -53,6 +57,10 @@ class Phone(fields.Char):
return res
class Phone(Fax):
type = 'phone'
def convert_phone_field(value, country_code):
_logger.debug(
'convert_phone_field value=%s country=%s', value, country_code)
@ -104,7 +112,7 @@ def convert_all_phone_fields(self, vals, fields_to_convert):
def get_phone_fields(self, vals):
fields_to_convert = []
for key in vals:
if isinstance(self._fields.get(key), Phone):
if isinstance(self._fields.get(key), Fax):
fields_to_convert.append(key)
return fields_to_convert

1
base_phone/models/__init__.py

@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
from . import controller
from . import res_company
from . import res_partner
from . import phone_common

14
base_phone/models/phone_common.py

@ -2,14 +2,16 @@
# © 2010-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import models, api
from openerp.addons.base_phone.fields import Phone
from odoo import models, api
from .. import fields as phone_fields
import logging
# Lib for phone number reformating -> pip install phonenumbers
import phonenumbers
_logger = logging.getLogger(__name__)
try:
import phonenumbers
except ImportError:
_logger.debug('Cannot `import phonenumbers`.')
class PhoneCommon(models.AbstractModel):
_name = 'phone.common'
@ -102,7 +104,7 @@ class PhoneCommon(models.AbstractModel):
for (obj, prio) in phoneobj_sorted:
entry = {'object': obj, 'fields': []}
for field in obj._fields:
if isinstance(obj._fields[field], Phone):
if isinstance(obj._fields[field], phone_fields.Phone):
entry['fields'].append(field)
res.append(entry)
# [{'fields': ['fax', 'phone', 'mobile'], 'object': res.partner()},

13
base_phone/models/res_company.py

@ -2,7 +2,8 @@
# © 2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import models, fields
from odoo import models, fields
from .. import fields as phone_fields
class ResCompany(models.Model):
@ -11,15 +12,19 @@ class ResCompany(models.Model):
number_of_digits_to_match_from_end = fields.Integer(
string='Number of Digits To Match From End',
default=8,
help="In several situations, OpenERP will have to find a "
help="In several situations, Odoo will have to find a "
"Partner/Lead/Employee/... from a phone number presented by the "
"calling party. As the phone numbers presented by your phone "
"operator may not always be displayed in a standard format, "
"the best method to find the related Partner/Lead/Employee/... "
"in OpenERP is to try to match the end of the phone number in "
"OpenERP with the N last digits of the phone number presented "
"in Odoo is to try to match the end of the phone number in "
"Odoo with the N last digits of the phone number presented "
"by the calling party. N is the value you should enter in this "
"field.")
phone = phone_fields.Phone(
country_field='country_id', partner_field='partner_id')
fax = phone_fields.Fax(
country_field='country_id', partner_field='partner_id')
_sql_constraints = [(
'number_of_digits_to_match_from_end_positive',

6
base_phone/models/res_partner.py

@ -3,8 +3,8 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import models, api
from openerp.addons.base_phone import fields
from odoo import models, api
from .. import fields
class ResPartner(models.Model):
@ -14,7 +14,7 @@ class ResPartner(models.Model):
phone = fields.Phone(country_field='country_id', partner_field='parent_id')
mobile = fields.Phone(
country_field='country_id', partner_field='parent_id')
fax = fields.Phone(country_field='country_id', partner_field='parent_id')
fax = fields.Fax(country_field='country_id', partner_field='parent_id')
@api.multi
def name_get(self):

14
base_phone/security/phone_security.xml

@ -5,13 +5,11 @@
The licence is in the file __openerp__.py
-->
<openerp>
<data noupdate="1">
<odoo noupdate="1">
<!-- New group dedicated to the "Get CallerID name from OpenERP" feature -->
<record id="group_callerid" model="res.groups">
<field name="name">Phone CallerID</field>
</record>
<!-- New group dedicated to the "Get CallerID name from OpenERP" feature -->
<record id="group_callerid" model="res.groups">
<field name="name">Phone CallerID</field>
</record>
</data>
</openerp>
</odoo>

155
base_phone/static/src/js/phone_widget.js

@ -3,15 +3,16 @@
The licence is in the file __openerp__.py */
odoo.define('base_phone.phone_widget', function (require) {
"use strict";
"use strict";
var core = require('web.core');
var formwidgets = require('web.form_widgets');
var web_client = require('web.web_client');
var _t = core._t;
var core = require('web.core');
var formwidgets = require('web.form_widgets');
var web_client = require('web.web_client');
var _t = core._t;
var FieldPhone = formwidgets.FieldChar.extend({
template: 'FieldPhone',
var FieldFax = formwidgets.FieldEmail.extend({
template: 'FieldFax',
prefix: 'fax',
initialize_content: function() {
this._super();
var $button = this.$el.find('button');
@ -19,36 +20,45 @@ var FieldPhone = formwidgets.FieldChar.extend({
this.setupFocus($button);
},
render_value: function() {
if (!this.get('effective_readonly')) {
this._super();
} else {
var self = this;
this._super();
if (this.get("effective_readonly") && this.clickable) {
var phone_num = this.get('value');
// console.log('BASE_PHONE phone_num = %s', phone_num);
var raw_phone_num = '';
if (phone_num) {
// remove non-breaking-space
raw_phone_num = phone_num.replace(/ /g, '');
raw_phone_num = raw_phone_num.replace(/-/g, '');
this.$el.find('a.oe_form_uri').attr('href', 'tel:' + raw_phone_num).text(phone_num);
if(phone_num) {
phone_num = phone_num.replace(/ /g, '').replace(/-/g, '');
this.$el.attr('href', this.prefix + ':' + phone_num);
}
else {
this.$el.find('a.oe_form_uri').attr('href', '').text('');
}
},
on_button_clicked: function() {
location.href = this.prefix + ':' + this.get('value');
}
});
var FieldPhone = FieldFax.extend({
template: 'FieldPhone',
prefix: 'tel',
render_value: function() {
this._super();
if (this.get("effective_readonly") && this.clickable) {
var self = this;
var phone_num = this.get('value');
if(phone_num) {
phone_num = phone_num.replace(/ /g, '').replace(/-/g, '');
}
var click2dial_text = '';
if (phone_num && !this.options.dial_button_invisible) {
click2dial_text = _t('Dial');
click2dial_text = _t('Dial');
}
this.$el.find('#click2dial').off('click');
this.$el.find('#click2dial')
.text(click2dial_text)
.on('click', function(ev) {
self.do_notify(
_t('Click2dial started'),
_t('Unhook your ringing phone'),
false);
_t('Click2dial started'),
_t('Unhook your ringing phone'),
false);
var arg = {
'phone_number': raw_phone_num,
'phone_number': phone_num,
'click2dial_model': self.view.dataset.model,
'click2dial_id': self.view.datarecord.id};
self.rpc('/base_phone/click2dial', arg).done(function(r) {
@ -57,15 +67,15 @@ var FieldPhone = formwidgets.FieldChar.extend({
self.do_warn("Click2dial failed");
} else if (typeof r === 'object') {
self.do_notify(
_t('Click2dial successfull'),
_t('Number dialed:') + ' ' + r.dialed_number,
false);
_t('Click2dial successfull'),
_t('Number dialed:') + ' ' + r.dialed_number,
false);
if (r.action_model) {
var context = {
'click2dial_model': self.view.dataset.model,
'click2dial_id': self.view.datarecord.id,
'phone_number': raw_phone_num,
};
'phone_number': phone_num,
};
var action = {
name: r.action_name,
type: 'ir.actions.act_window',
@ -74,80 +84,47 @@ var FieldPhone = formwidgets.FieldChar.extend({
views: [[false, 'form']],
target: 'new',
context: context,
};
};
web_client.action_manager.do_action(action);
}
}
});
});
}
},
on_button_clicked: function() {
location.href = 'tel:' + this.get('value');
}
});
// To avoid conflicts, we check that widgets do not exist before using
if(!core.form_widget_registry.get('fax')){
core.form_widget_registry.add('fax', FieldFax);
}
var FieldFax = formwidgets.FieldChar.extend({
template: 'FieldFax',
initialize_content: function() {
this._super();
var $button = this.$el.find('button');
$button.click(this.on_button_clicked);
this.setupFocus($button);
},
render_value: function() {
if (!this.get('effective_readonly')) {
this._super();
} else {
var fax_num = this.get('value');
// console.log('BASE_PHONE fax_num = %s', fax_num);
if (fax_num) {
var raw_fax_num = fax_num.replace(/ /g, '');
raw_fax_num = raw_fax_num.replace(/-/g, '');
this.$el.find('a').attr('href', 'fax:' + raw_fax_num).text(fax_num);
}
else {
this.$el.find('a').attr('href', '').text('');
}
}
},
on_button_clicked: function() {
location.href = 'fax:' + this.get('value');
}
});
// To avoid conflicts, we check that widgets do not exist before using
if(!core.form_widget_registry.get('fax')){
core.form_widget_registry.add('fax', FieldFax);
}
if(!core.form_widget_registry.get('phone')){
core.form_widget_registry.add('phone', FieldPhone);
}
if(!core.form_widget_registry.get('phone')){
core.form_widget_registry.add('phone', FieldPhone);
}
var treewidgets = require('web.ListView');
var treewidgets = require('web.ListView');
var ColumnPhone = treewidgets.Column.extend({
// ability to add widget="phone" in TREE view
_format: function(row_data, options) {
var phone_num = row_data[this.id].value;
if (phone_num) {
var raw_phone_num = phone_num.replace(/ /g, '');
raw_phone_num = raw_phone_num.replace(/-/g, '');
return _.template("<a href='tel:<%-href%>'><%-text%></a>")({
href: raw_phone_num,
text: phone_num
});
var ColumnPhone = treewidgets.Column.extend({
// ability to add widget="phone" in TREE view
_format: function(row_data, options) {
var phone_num = row_data[this.id].value;
if (phone_num) {
var raw_phone_num = phone_num.replace(/ /g, '');
raw_phone_num = raw_phone_num.replace(/-/g, '');
return _.template("<a href='tel:<%-href%>'><%-text%></a>")({
href: raw_phone_num,
text: phone_num
});
}
return this._super(row_data, options);
}
return this._super(row_data, options);
}
});
});
if (!core.list_widget_registry.get('phone')) {
core.list_widget_registry.add('field.phone', ColumnPhone);
}
if (!core.list_widget_registry.get('phone')) {
core.list_widget_registry.add('field.phone', ColumnPhone);
}
});

12
base_phone/static/src/xml/phone.xml

@ -7,16 +7,12 @@
<templates id="template" xml:space="preserve">
<t t-name="FieldPhone" t-extend="FieldEmail">
<t t-jquery="span:first">
this.removeClass('oe_form_field_email').addClass('oe_form_field_phone');
<t t-name="FieldFax">
<t t-call="FieldEmail"/>
</t>
</t>
<t t-name="FieldFax" t-extend="FieldEmail">
<t t-jquery="span:first">
this.removeClass('oe_form_field_email').addClass('oe_form_field_fax');
<t t-name="FieldPhone">
<t t-call="FieldFax"/>
</t>
</t>
</templates>

1
base_phone/tests/test_phone.py

@ -26,7 +26,6 @@ class TestPhone(TransactionCase):
partner2 = rpo.create({
'name': u'Joël Grand-Guillaume',
'parent_id': self.env.ref('base.res_partner_12').id,
'use_parent_address': True,
'phone': '(0) 21 619 10 10',
'mobile': '(0) 79 606 42 42',
})

33
base_phone/views/res_company_view.xml

@ -6,27 +6,20 @@
-->
<odoo>
<data>
<record id="view_company_form" model="ir.ui.view">
<field name="name">base_phone.company.form</field>
<field name="model">res.company</field>
<field name="inherit_id" ref="base.view_company_form" />
<field name="arch" type="xml">
<group name="account_grp" position="after">
<group name="phone" string="Phone">
<field name="number_of_digits_to_match_from_end" />
</group>
</group>
<field name="phone" position="attributes">
<attribute name="widget">phone</attribute>
<record id="view_company_form" model="ir.ui.view">
<field name="name">base_phone.company.form</field>
<field name="model">res.company</field>
<field name="inherit_id" ref="base.view_company_form" />
<field name="arch" type="xml">
<xpath expr="//notebook" position="inside">
<page string="Phone">
<group name="phone" string="Phone">
<field name="number_of_digits_to_match_from_end" />
</group>
</page>
</xpath>
</field>
<field name="fax" position="attributes">
<attribute name="widget">fax</attribute>
</field>
</field>
</record>
</record>
</data>
</odoo>

30
base_phone/views/res_partner_view.xml

@ -5,33 +5,9 @@
-->
<odoo>
<data>
<record id="view_partner_form" model="ir.ui.view">
<field name="name">base.phone.res.partner.form</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<xpath expr="//group/group/field[@name='fax']" position="attributes">
<attribute name="widget">fax</attribute>
</xpath>
</field>
</record>
<record id="base.action_partner_form" model="ir.actions.act_window">
<field name="context">{'search_default_customer': 1, 'raise_if_phone_parse_fails': True}</field>
</record>
<record id="view_partner_tree" model="ir.ui.view">
<field name="name">base_phone.phone.widget.partner.tree</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_tree"/>
<field name="arch" type="xml">
<field name="phone" position="attributes">
<attribute name="widget">phone</attribute>
</field>
</field>
</record>
<record id="base.action_partner_form" model="ir.actions.act_window">
<field name="context">{'search_default_customer': 1, 'raise_if_phone_parse_fails': True}</field>
</record>
</data>
</odoo>

54
base_phone/views/res_users_view.xml

@ -5,35 +5,33 @@
-->
<odoo>
<data>
<record id="view_users_form" model="ir.ui.view">
<field name="name">base_phone.res.users.telephony_tab</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="base.view_users_form"/>
<field name="arch" type="xml">
<notebook position="inside">
<page string="Telephony" name="phone" invisible="1">
<!-- Empty page, which will be used by other phone modules -->
<group name="phone-preferences" string="Telephony Preferences">
</group>
</page>
</notebook>
</field>
</record>
<record id="view_users_form" model="ir.ui.view">
<field name="name">base_phone.res.users.telephony_tab</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="base.view_users_form"/>
<field name="arch" type="xml">
<notebook position="inside">
<page string="Telephony" name="phone" invisible="1">
<!-- Empty page, which will be used by other phone modules -->
<group name="phone-preferences" string="Telephony Preferences">
</group>
</page>
</notebook>
</field>
</record>
<record id="view_users_form_simple_modif" model="ir.ui.view">
<field name="name">base_phone.user_preferences.view</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="base.view_users_form_simple_modif" />
<field name="arch" type="xml">
<xpath expr="//field[@name='email']/.." position="after">
<group name="phone" string="Telephony Preferences" invisible="1">
<!-- Empty group, that is used by other phone modules -->
</group>
</xpath>
</field>
</record>
<record id="view_users_form_simple_modif" model="ir.ui.view">
<field name="name">base_phone.user_preferences.view</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="base.view_users_form_simple_modif" />
<field name="arch" type="xml">
<xpath expr="//field[@name='email']/.." position="after">
<group name="phone" string="Telephony Preferences" invisible="1">
<!-- Empty group, that is used by other phone modules -->
</group>
</xpath>
</field>
</record>
</data>
</odoo>

18
base_phone/web_phone.xml

@ -5,17 +5,13 @@
-->
<odoo>
<data>
<template id="assets_backend" name="base_phone assets"
inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript"
src="/base_phone/static/src/js/phone_widget.js"></script>
</xpath>
</template>
<template id="assets_backend" name="base_phone assets"
inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript"
src="/base_phone/static/src/js/phone_widget.js"></script>
</xpath>
</template>
</data>
</odoo>

46
base_phone/wizard/number_not_found.py

@ -2,39 +2,43 @@
# © 2010-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import models, fields, api, _
from openerp.exceptions import UserError
from odoo import models, fields, api, _
from .. import fields as phone_fields
from odoo.exceptions import UserError
import logging
import phonenumbers
_logger = logging.getLogger(__name__)
try:
import phonenumbers
except ImportError:
_logger.debug('Cannot `import phonenumbers`.')
class NumberNotFound(models.TransientModel):
_name = "number.not.found"
_description = "Number not found"
calling_number = fields.Char(string='Calling Number', size=64,
readonly=True,
help="Phone number of calling party that has "
"been obtained from the telephony server, in "
"the format used by the telephony server "
"(not E.164).")
e164_number = fields.Char(string='E.164 Number', size=64,
help="E.164 equivalent of the calling number.")
calling_number = fields.Char(
string='Calling Number', size=64, readonly=True,
help="Phone number of calling party that has been obtained from the "
"telephony server, in the format used by the telephony server (not "
"E.164).")
e164_number = fields.Char(
string='E.164 Number', size=64,
help="E.164 equivalent of the calling number.")
number_type = fields.Selection(selection=[
('phone', 'Fixed'),
('mobile', 'Mobile')
], string='Fixed/Mobile', required=True)
to_update_partner_id = fields.Many2one(comodel_name='res.partner',
string='Partner to Update',
help="Partner on which the phone "
"number will be written")
current_partner_phone = fields.Char(related='to_update_partner_id.phone',
string='Current Phone', readonly=True)
current_partner_mobile = fields.Char(related='to_update_partner_id.mobile',
string='Current Mobile',
readonly=True)
to_update_partner_id = fields.Many2one(
comodel_name='res.partner', string='Partner to Update',
help="Partner on which the phone number will be written")
current_partner_phone = phone_fields.Phone(
related='to_update_partner_id.phone', string='Current Phone',
readonly=True)
current_partner_mobile = phone_fields.Phone(
related='to_update_partner_id.mobile', string='Current Mobile',
readonly=True)
@api.model
def default_get(self, fields_list):

80
base_phone/wizard/number_not_found_view.xml

@ -5,49 +5,45 @@
-->
<odoo>
<data>
<record id="number_not_found_form" model="ir.ui.view">
<field name="name">number.not.found.form</field>
<field name="model">number.not.found</field>
<field name="arch" type="xml">
<form string="Number Not Found">
<div class="oe_title">
<h1>
<field name="calling_number" />
</h1>
<label string="Number converted to international format:"
for="e164_number"/>
<h2>
<field name="e164_number" />
</h2>
<label for="number_type"/>
<h3>
<field name="number_type"/>
</h3>
</div>
<group colspan="4" col="2" name="create-update">
<group name="partner" string="Create or Update a Partner"
colspan="1" col="2">
<button name="create_partner" class="oe_highlight" colspan="2"
string="Create Partner with this Number" type="object"/>
<field name="to_update_partner_id" />
<field name="current_partner_phone" widget="phone"
options="{'dial_button_invisible': True}"/>
<field name="current_partner_mobile" widget="phone"
options="{'dial_button_invisible': True}"/>
<button name="update_partner" class="oe_highlight" colspan="2"
string="Update Partner with this Number" type="object"/>
<record id="number_not_found_form" model="ir.ui.view">
<field name="name">number.not.found.form</field>
<field name="model">number.not.found</field>
<field name="arch" type="xml">
<form string="Number Not Found">
<div class="oe_title">
<h1>
<field name="calling_number" />
</h1>
<label string="Number converted to international format:"
for="e164_number"/>
<h2>
<field name="e164_number" />
</h2>
<label for="number_type"/>
<h3>
<field name="number_type"/>
</h3>
</div>
<group colspan="4" col="2" name="create-update">
<group name="partner" string="Create or Update a Partner"
colspan="1" col="2">
<button name="create_partner" class="oe_highlight" colspan="2"
string="Create Partner with this Number" type="object"/>
<field name="to_update_partner_id" />
<field name="current_partner_phone"
options="{'dial_button_invisible': True}"/>
<field name="current_partner_mobile"
options="{'dial_button_invisible': True}"/>
<button name="update_partner" class="oe_highlight" colspan="2"
string="Update Partner with this Number" type="object"/>
</group>
</group>
</group>
<footer>
<button special="cancel" string="Close" class="oe_link"/>
</footer>
</form>
</field>
</record>
<footer>
<button special="cancel" string="Close" class="oe_link"/>
</footer>
</form>
</field>
</record>
</data>
</odoo>

2
base_phone/wizard/reformat_all_phonenumbers.py

@ -2,7 +2,7 @@
# © 2012-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import models, fields, api
from odoo import models, fields, api
import logging
logger = logging.getLogger(__name__)

80
base_phone/wizard/reformat_all_phonenumbers_view.xml

@ -5,50 +5,48 @@
The licence is in the file __openerp__.py
-->
<openerp>
<data>
<odoo>
<record id="reformat_all_phonenumbers_form" model="ir.ui.view">
<field name="name">reformat_all_phonenumbers.form</field>
<field name="model">reformat.all.phonenumbers</field>
<field name="arch" type="xml">
<form string="Reformat all phone numbers">
<group name="main">
<label string="This wizard reformats the phone, mobile and fax numbers of all partners in standard international format e.g. +33141981242" colspan="2" states="draft"/>
<label colspan="2" string="Phone numbers that couldn't be reformatted:" states="done"/>
<field name="phonenumbers_not_reformatted" colspan="2" nolabel="1" states="done"/>
<field name="state" invisible="1"/>
</group>
<footer>
<button name="run_reformat_all_phonenumbers"
string="Reformat all phone numbers" type="object"
class="oe_highlight" states="draft"/>
<button name="action_next" type="object" string="Close"
class="oe_highlight" states="done"/>
<button special="cancel" string="Cancel"
class="oe_link" states="draft"/>
</footer>
</form>
</field>
</record>
<record id="reformat_all_phonenumbers_form" model="ir.ui.view">
<field name="name">reformat_all_phonenumbers.form</field>
<field name="model">reformat.all.phonenumbers</field>
<field name="arch" type="xml">
<form string="Reformat all phone numbers">
<group name="main">
<label string="This wizard reformats the phone, mobile and fax numbers of all partners in standard international format e.g. +33141981242" colspan="2" states="draft"/>
<label colspan="2" string="Phone numbers that couldn't be reformatted:" states="done"/>
<field name="phonenumbers_not_reformatted" colspan="2" nolabel="1" states="done"/>
<field name="state" invisible="1"/>
</group>
<footer>
<button name="run_reformat_all_phonenumbers"
string="Reformat all phone numbers" type="object"
class="oe_highlight" states="draft"/>
<button name="action_next" type="object" string="Close"
class="oe_highlight" states="done"/>
<button special="cancel" string="Cancel"
class="oe_link" states="draft"/>
</footer>
</form>
</field>
</record>
<record id="reformat_all_phonenumbers_action" model="ir.actions.act_window">
<field name="name">Reformat Phone Numbers</field>
<field name="res_model">reformat.all.phonenumbers</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<record id="reformat_all_phonenumbers_action" model="ir.actions.act_window">
<field name="name">Reformat Phone Numbers</field>
<field name="res_model">reformat.all.phonenumbers</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<!-- Menu entry under Settings > Technical -->
<menuitem id="menu_config_phone" name="Telephony" parent="base.menu_custom"/>
<!-- Menu entry under Settings > Technical -->
<menuitem id="menu_config_phone" name="Telephony" parent="base.menu_custom"/>
<menuitem id="reformat_all_phonenumbers_menu" action="reformat_all_phonenumbers_action" parent="menu_config_phone" sequence="100"/>
<menuitem id="reformat_all_phonenumbers_menu" action="reformat_all_phonenumbers_action" parent="menu_config_phone" sequence="100"/>
<!-- Open the Reformat Phone Numbers wizard after the installation of the module -->
<record id="reformat_all_phonenumbers_module_install" model="ir.actions.todo">
<field name="action_id" ref="reformat_all_phonenumbers_action"/>
<field name="type">automatic</field>
</record>
<!-- Open the Reformat Phone Numbers wizard after the installation of the module -->
<record id="reformat_all_phonenumbers_module_install" model="ir.actions.todo">
<field name="action_id" ref="reformat_all_phonenumbers_action"/>
<field name="type">automatic</field>
</record>
</data>
</openerp>
</odoo>
Loading…
Cancel
Save