diff --git a/base_phone/README.rst b/base_phone/README.rst index 35a6bdc35..47f3661bb 100644 --- a/base_phone/README.rst +++ b/base_phone/README.rst @@ -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| @@ -43,7 +43,7 @@ Bug Tracker Bugs are tracked on `GitHub 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -60,6 +60,15 @@ Contributors * Alexis de Lattre * Sébastien Beau +* `Trobz `_: + + * Hung Huynh Ngoc + * Nguyễn Minh Chiến + +Other credits +~~~~~~~~~~~~~ + +The migration of this module from 15.0 to 16.0 was financially supported by Camptocamp Maintainers ~~~~~~~~~~~ @@ -82,6 +91,6 @@ Current `maintainer `__: |maintainer-alexis-via| -This module is part of the `OCA/connector-telephony `_ project on GitHub. +This module is part of the `OCA/connector-telephony `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/base_phone/__manifest__.py b/base_phone/__manifest__.py index b53f7368e..03924a127 100644 --- a/base_phone/__manifest__.py +++ b/base_phone/__manifest__.py @@ -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", diff --git a/base_phone/i18n/base_phone.pot b/base_phone/i18n/base_phone.pot index 1de8c1fe1..50510989f 100644 --- a/base_phone/i18n/base_phone.pot +++ b/base_phone/i18n/base_phone.pot @@ -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" diff --git a/base_phone/i18n/es_AR.po b/base_phone/i18n/es_AR.po index 701f0c0c5..52783c2bc 100644 --- a/base_phone/i18n/es_AR.po +++ b/base_phone/i18n/es_AR.po @@ -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 \n" diff --git a/base_phone/models/__init__.py b/base_phone/models/__init__.py index 7d7547ee7..813947dd3 100644 --- a/base_phone/models/__init__.py +++ b/base_phone/models/__init__.py @@ -1,4 +1,3 @@ -from . import phone_validation_mixin from . import res_company from . import res_partner from . import phone_common diff --git a/base_phone/models/phone_common.py b/base_phone/models/phone_common.py index 9b637dc73..824471939 100644 --- a/base_phone/models/phone_common.py +++ b/base_phone/models/phone_common.py @@ -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 ) @@ -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 = [] diff --git a/base_phone/models/phone_validation_mixin.py b/base_phone/models/phone_validation_mixin.py deleted file mode 100644 index 14566fda5..000000000 --- a/base_phone/models/phone_validation_mixin.py +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright 2018-2021 Akretion France (http://www.akretion.com/) -# @author: Alexis de Lattre -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - - -from odoo import models - -from odoo.addons.phone_validation.tools import phone_validation - - -class PhoneValidationMixin(models.AbstractModel): - _name = "phone.validation.mixin" - _description = "Phone Validation Mixin" - - def _phone_get_country(self): - if "country_id" in self and self.country_id: - return self.country_id - if "partner_id" in self and self.partner_id and self.partner_id.country_id: - return self.partner_id.country_id - return self.env.company.country_id - - def phone_format(self, number, country=None, company=None): - country = country or self._phone_get_country() - if not country: - return number - return phone_validation.phone_format( - number, - country.code if country else None, - country.phone_code if country else None, - force_format="INTERNATIONAL", - raise_exception=False, - ) diff --git a/base_phone/models/res_partner.py b/base_phone/models/res_partner.py index c38901ff6..b6a5b66f1 100644 --- a/base_phone/models/res_partner.py +++ b/base_phone/models/res_partner.py @@ -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"): diff --git a/base_phone/readme/CONTRIBUTORS.rst b/base_phone/readme/CONTRIBUTORS.rst index 929705395..e2ed68d2c 100644 --- a/base_phone/readme/CONTRIBUTORS.rst +++ b/base_phone/readme/CONTRIBUTORS.rst @@ -1,2 +1,6 @@ * Alexis de Lattre * Sébastien Beau +* `Trobz `_: + + * Hung Huynh Ngoc + * Nguyễn Minh Chiến diff --git a/base_phone/readme/CREDITS.rst b/base_phone/readme/CREDITS.rst new file mode 100644 index 000000000..70bc307ad --- /dev/null +++ b/base_phone/readme/CREDITS.rst @@ -0,0 +1 @@ +The migration of this module from 15.0 to 16.0 was financially supported by Camptocamp diff --git a/base_phone/static/description/index.html b/base_phone/static/description/index.html index 9e975e356..831b7f6fb 100644 --- a/base_phone/static/description/index.html +++ b/base_phone/static/description/index.html @@ -3,7 +3,7 @@ - + Base Phone