Browse Source

Merge PR #1013 into 14.0

Signed-off-by dreispt
14.0
OCA-git-bot 4 years ago
parent
commit
dec19222f2
  1. 1
      partner_phone_secondary/__init__.py
  2. 15
      partner_phone_secondary/__manifest__.py
  3. 1
      partner_phone_secondary/models/__init__.py
  4. 17
      partner_phone_secondary/models/res_partner.py
  5. 1
      partner_phone_secondary/readme/CONTRIBUTORS.rst
  6. 1
      partner_phone_secondary/readme/DESCRIPTION.rst
  7. 1
      partner_phone_secondary/tests/__init__.py
  8. 19
      partner_phone_secondary/tests/test_partner_phone_secondary.py
  9. 19
      partner_phone_secondary/views/res_partner.xml
  10. 1
      setup/partner_phone_secondary/odoo/addons/partner_phone_secondary
  11. 6
      setup/partner_phone_secondary/setup.py

1
partner_phone_secondary/__init__.py

@ -0,0 +1 @@
from . import models

15
partner_phone_secondary/__manifest__.py

@ -0,0 +1,15 @@
# Copyright 2020 - Iván Todorovich
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Secondary phone number on partners",
"summary": "Adds a secondary phone number on partners",
"license": "AGPL-3",
"version": "14.0.1.0.0",
"author": "Iván Todorovich, Odoo Community Association (OCA)",
"maintainers": ["ivantodorovich"],
"category": "Customer Relationship Management",
"depends": ["base"],
"website": "https://github.com/OCA/partner-contact",
"data": ["views/res_partner.xml"],
}

1
partner_phone_secondary/models/__init__.py

@ -0,0 +1 @@
from . import res_partner

17
partner_phone_secondary/models/res_partner.py

@ -0,0 +1,17 @@
# Copyright 2020 - Iván Todorovich
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
class ResPartner(models.Model):
_inherit = "res.partner"
phone2 = fields.Char("Phone (Secondary)")
@api.onchange("phone2", "country_id", "company_id")
def _onchange_phone2_validation(self):
# Compatibility with phone_validation
if hasattr(self, "phone_format"):
if self.phone2:
self.phone2 = self.phone_format(self.phone2)

1
partner_phone_secondary/readme/CONTRIBUTORS.rst

@ -0,0 +1 @@
* Iván Todorovich <ivan.todorovich@gmail.com>

1
partner_phone_secondary/readme/DESCRIPTION.rst

@ -0,0 +1 @@
Adds a secondary phone number on partners

1
partner_phone_secondary/tests/__init__.py

@ -0,0 +1 @@
from . import test_partner_phone_secondary

19
partner_phone_secondary/tests/test_partner_phone_secondary.py

@ -0,0 +1,19 @@
# Copyright 2020 - Iván Todorovich
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo.tests.common import Form, TransactionCase
class TestPartnerPhoneSecondary(TransactionCase):
def test_01_phone_validation_compatibility(self):
# This is here only to get code coverage.
with Form(self.env["res.partner"]) as form:
form.name = "French Partner"
form.country_id = self.env.ref("base.fr")
form.phone = "766666666"
form.phone2 = "766666666"
# It's not the purpose of this module to test phone_validation,
# nor how it formats phone numbers. Also it's not directly depended
# by this module. We do know for sure, though, that the same number
# is going to be formatted in the exact same way.
self.assertEqual(form.phone, form.phone2)

19
partner_phone_secondary/views/res_partner.xml

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
Copyright 2020 - Iván Todorovich
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
-->
<odoo>
<record id="view_partner_form" model="ir.ui.view">
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form" />
<field name="priority" eval="1" />
<field name="arch" type="xml">
<field name="phone" position="after">
<field name="phone2" widget="phone" />
</field>
</field>
</record>
</odoo>

1
setup/partner_phone_secondary/odoo/addons/partner_phone_secondary

@ -0,0 +1 @@
../../../../partner_phone_secondary

6
setup/partner_phone_secondary/setup.py

@ -0,0 +1,6 @@
import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
Loading…
Cancel
Save