Skip to content

Commit

Permalink
[16.0][MIG] base_phone: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenminhchien committed Mar 16, 2023
1 parent 50e227d commit 460e269
Show file tree
Hide file tree
Showing 12 changed files with 63 additions and 68 deletions.
23 changes: 16 additions & 7 deletions base_phone/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ Base Phone
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fconnector--telephony-lightgray.png?logo=github
:target: https://github.com/OCA/connector-telephony/tree/14.0/base_phone
:target: https://github.com/OCA/connector-telephony/tree/16.0/base_phone
:alt: OCA/connector-telephony
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/connector-telephony-14-0/connector-telephony-14-0-base_phone
:target: https://translation.odoo-community.org/projects/connector-telephony-16-0/connector-telephony-16-0-base_phone
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/228/14.0
:alt: Try me on Runbot
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/webui/builds.html?repo=OCA/connector-telephony&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

Expand All @@ -43,7 +43,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/connector-telephony/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/connector-telephony/issues/new?body=module:%20base_phone%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/connector-telephony/issues/new?body=module:%20base_phone%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Expand All @@ -60,6 +60,15 @@ Contributors

* Alexis de Lattre <[email protected]>
* Sébastien Beau <[email protected]>
* `Trobz <https://trobz.com>`_:

* Hung Huynh Ngoc <[email protected]>
* Nguyễn Minh Chiến <[email protected]>

Other credits
~~~~~~~~~~~~~

The migration of this module from 15.0 to 16.0 was financially supported by Camptocamp

Maintainers
~~~~~~~~~~~
Expand All @@ -82,6 +91,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-alexis-via|

This module is part of the `OCA/connector-telephony <https://github.com/OCA/connector-telephony/tree/14.0/base_phone>`_ project on GitHub.
This module is part of the `OCA/connector-telephony <https://github.com/OCA/connector-telephony/tree/16.0/base_phone>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion base_phone/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

{
"name": "Base Phone",
"version": "15.0.1.0.0",
"version": "16.0.1.0.0",
"category": "Phone",
"license": "AGPL-3",
"summary": "Validate phone numbers",
Expand Down
2 changes: 1 addition & 1 deletion base_phone/i18n/base_phone.pot
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
Expand Down
2 changes: 1 addition & 1 deletion base_phone/i18n/es_AR.po
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2022-08-05 17:06+0000\n"
"Last-Translator: Nicolas Rodriguez Sande <[email protected]>\n"
Expand Down
1 change: 0 additions & 1 deletion base_phone/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from . import phone_validation_mixin
from . import res_company
from . import res_partner
from . import phone_common
21 changes: 11 additions & 10 deletions base_phone/models/phone_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,14 @@ def get_record_from_phone_number(self, presented_number):
obj._name,
end_number_to_match,
)
sql = "SELECT id FROM %s WHERE " % obj._table
sql = "SELECT id FROM %s " % obj._table
sql_where = []
sql_args = []
for field in obj_dict["fields"]:
sql_where.append("replace(%s, ' ', '') ilike %%s" % field)
sql_args.append(pg_search_number)
sql += " or ".join(sql_where)
if sql_where:
sql += " WHERE " + " or ".join(sql_where)
_logger.debug(
"get_record_from_phone_number sql=%s sql_args=%s", sql, sql_args
)
Expand Down Expand Up @@ -118,17 +119,17 @@ def _get_phone_models(self):
senv = self.with_context(callerid=True).env[model_name]
except Exception:
continue
if (
hasattr(senv, "_phone_name_sequence")
and isinstance(senv._phone_name_sequence, int)
and hasattr(senv, "_phone_name_fields")
and isinstance(senv._phone_name_fields, list)
):
if not isinstance(senv, models.Model):
continue
if hasattr(senv, "_phone_get_number_fields"):
cdict = {
"object": senv,
"fields": senv._phone_name_fields,
"fields": senv._phone_get_number_fields(),
}
phoneobj.append((senv._phone_name_sequence, cdict))
seq = 100
if hasattr(senv, "_phone_name_sequence"):
seq = senv._phone_name_sequence
phoneobj.append((seq, cdict))

phoneobj_sorted = sorted(phoneobj, key=lambda element: element[0])
res = []
Expand Down
32 changes: 0 additions & 32 deletions base_phone/models/phone_validation_mixin.py

This file was deleted.

8 changes: 2 additions & 6 deletions base_phone/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@


class ResPartner(models.Model):
_name = "res.partner"
# inherit on phone.validation.mixin (same as in crm_phone_validation,
# but base_phone only depends on phone_validation,
# not on crm_phone_validation)
_inherit = ["res.partner", "phone.validation.mixin"]
_inherit = "res.partner"

_phone_name_sequence = 10
_phone_name_fields = ["phone", "mobile"]

def name_get(self):
if self._context.get("callerid"):
Expand Down
4 changes: 4 additions & 0 deletions base_phone/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
* Alexis de Lattre <[email protected]>
* Sébastien Beau <[email protected]>
* `Trobz <https://trobz.com>`_:

* Hung Huynh Ngoc <[email protected]>
* Nguyễn Minh Chiến <[email protected]>
1 change: 1 addition & 0 deletions base_phone/readme/CREDITS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The migration of this module from 15.0 to 16.0 was financially supported by Camptocamp
31 changes: 23 additions & 8 deletions base_phone/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<title>Base Phone</title>
<style type="text/css">

Expand Down Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Base Phone</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/connector-telephony/tree/14.0/base_phone"><img alt="OCA/connector-telephony" src="https://img.shields.io/badge/github-OCA%2Fconnector--telephony-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/connector-telephony-14-0/connector-telephony-14-0-base_phone"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/228/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/connector-telephony/tree/16.0/base_phone"><img alt="OCA/connector-telephony" src="https://img.shields.io/badge/github-OCA%2Fconnector--telephony-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/connector-telephony-16-0/connector-telephony-16-0-base_phone"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runboat.odoo-community.org/webui/builds.html?repo=OCA/connector-telephony&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module provides common methods and wizards which can be useful to develop a connector between Odoo and a telephony system. It depends on the official module <em>phone_validation</em> which handle the reformatting of phone numbers using the <a class="reference external" href="https://github.com/daviddrysdale/python-phonenumbers">phonenumbers</a> Python library, which is a port of the library used in Android smartphones. For example, if
your user is linked to a French company and you update the form view of a
partner with a badly written French phone number such as ‘01-55-42-12-42’,
Expand All @@ -380,7 +380,8 @@ <h1 class="title">Base Phone</h1>
<li><a class="reference internal" href="#credits" id="id2">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id3">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id4">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id5">Maintainers</a></li>
<li><a class="reference internal" href="#other-credits" id="id5">Other credits</a></li>
<li><a class="reference internal" href="#maintainers" id="id6">Maintainers</a></li>
</ul>
</li>
</ul>
Expand All @@ -390,7 +391,7 @@ <h1><a class="toc-backref" href="#id1">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/connector-telephony/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/connector-telephony/issues/new?body=module:%20base_phone%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/connector-telephony/issues/new?body=module:%20base_phone%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand All @@ -403,21 +404,35 @@ <h2><a class="toc-backref" href="#id3">Authors</a></h2>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#id4">Contributors</a></h2>
<ul>
<li><p class="first">Alexis de Lattre &lt;<a class="reference external" href="mailto:alexis.delattre&#64;akretion.com">alexis.delattre&#64;akretion.com</a>&gt;</p>
</li>
<li><p class="first">Sébastien Beau &lt;<a class="reference external" href="mailto:sebastien.beau&#64;akretion.com">sebastien.beau&#64;akretion.com</a>&gt;</p>
</li>
<li><p class="first"><a class="reference external" href="https://trobz.com">Trobz</a>:</p>
<blockquote>
<ul class="simple">
<li>Alexis de Lattre &lt;<a class="reference external" href="mailto:alexis.delattre&#64;akretion.com">alexis.delattre&#64;akretion.com</a>&gt;</li>
<li>Sébastien Beau &lt;<a class="reference external" href="mailto:sebastien.beau&#64;akretion.com">sebastien.beau&#64;akretion.com</a>&gt;</li>
<li>Hung Huynh Ngoc &lt;<a class="reference external" href="mailto:hunghn&#64;trobz.com">hunghn&#64;trobz.com</a>&gt;</li>
<li>Nguyễn Minh Chiến &lt;<a class="reference external" href="mailto:chien&#64;trobz.com">chien&#64;trobz.com</a>&gt;</li>
</ul>
</blockquote>
</li>
</ul>
</div>
<div class="section" id="other-credits">
<h2><a class="toc-backref" href="#id5">Other credits</a></h2>
<p>The migration of this module from 15.0 to 16.0 was financially supported by Camptocamp</p>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#id5">Maintainers</a></h2>
<h2><a class="toc-backref" href="#id6">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external" href="https://github.com/alexis-via"><img alt="alexis-via" src="https://github.com/alexis-via.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/connector-telephony/tree/14.0/base_phone">OCA/connector-telephony</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/connector-telephony/tree/16.0/base_phone">OCA/connector-telephony</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
4 changes: 3 additions & 1 deletion base_phone/wizard/reformat_all_phonenumbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ def run_reformat_all_phonenumbers(self):
for obj_dict in phoneobjects:
fields = obj_dict["fields"]
obj = obj_dict["object"]
if not hasattr(obj, "_phone_format"):
continue
logger.info(
"Starting to reformat phone numbers on object %s " "(fields = %s)",
obj._name,
Expand All @@ -38,7 +40,7 @@ def run_reformat_all_phonenumbers(self):
vals = {}
for field in fields:
if entry[field]:
new_phone = entry.phone_format(entry[field])
new_phone = entry._phone_format(entry[field])
if new_phone != entry[field]:
vals[field] = new_phone
if vals:
Expand Down

0 comments on commit 460e269

Please sign in to comment.