Skip to content

Commit

Permalink
Merge PR #1936 into 17.0
Browse files Browse the repository at this point in the history
Signed-off-by dreispt
  • Loading branch information
OCA-git-bot committed Jan 28, 2025
2 parents b73d6c5 + 24292b4 commit 571bdcc
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 8 deletions.
12 changes: 7 additions & 5 deletions partner_fax/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,13 @@ Credits
Contributors
------------

- Francesco Apruzzese <[email protected]>
- Aitor Bouzas <[email protected]>
- Pimolnat Suntian <[email protected]>
- Nadal Francisco Garcia <[email protected]>
(https://braintec.com)
- Francesco Apruzzese <[email protected]>
- Aitor Bouzas <[email protected]>
- Pimolnat Suntian <[email protected]>
- Nadal Francisco Garcia <[email protected]>
(https://braintec.com)
- Iván Todorovich <[email protected]>
(https://www.camptocamp.com)

Maintainers
-----------
Expand Down
2 changes: 1 addition & 1 deletion partner_fax/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"author": "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/partner-contact",
"depends": ["base_setup"],
"data": ["views/res_partner.xml"],
"data": ["views/res_partner.xml", "views/templates.xml"],
"installable": True,
}
19 changes: 19 additions & 0 deletions partner_fax/models/ir_qweb_fields.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2024 Camptocamp SA (https://www.camptocamp.com).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import _, api, models


class Contact(models.AbstractModel):
_inherit = "ir.qweb.field.contact"

@api.model
def get_available_options(self):
options = super().get_available_options()
options["fields"]["params"]["params"].append(
{
"field_name": "fax",
"label": _("Fax"),
}
)
return options
4 changes: 2 additions & 2 deletions partner_fax/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- Francesco Apruzzese \<<[email protected]>\>
- Aitor Bouzas \<<[email protected]>\>
- Pimolnat Suntian \<<[email protected]>\>
- Nadal Francisco Garcia \<<[email protected]>\>
(<https://braintec.com>)
- Nadal Francisco Garcia \<<[email protected]>\> (<https://braintec.com>)
- Iván Todorovich \<<[email protected]>\> (<https://www.camptocamp.com>)
2 changes: 2 additions & 0 deletions partner_fax/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,8 @@ <h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
<li>Pimolnat Suntian &lt;<a class="reference external" href="mailto:pimolnats&#64;ecosoft.co.th">pimolnats&#64;ecosoft.co.th</a>&gt;</li>
<li>Nadal Francisco Garcia &lt;<a class="reference external" href="mailto:nadal.francisco&#64;braintec.com">nadal.francisco&#64;braintec.com</a>&gt;
(<a class="reference external" href="https://braintec.com">https://braintec.com</a>)</li>
<li>Iván Todorovich &lt;<a class="reference external" href="mailto:ivan.todorovich&#64;camptocamp.com">ivan.todorovich&#64;camptocamp.com</a>&gt;
(<a class="reference external" href="https://www.camptocamp.com">https://www.camptocamp.com</a>)</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
1 change: 1 addition & 0 deletions partner_fax/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_qweb_contact_field
37 changes: 37 additions & 0 deletions partner_fax/tests/test_qweb_contact_field.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright 2024 Camptocamp SA (https://www.camptocamp.com).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo.tests import TransactionCase

from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT


class TestQwebContactField(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.env = cls.env(context=dict(cls.env.context, **DISABLED_MAIL_CONTEXT))
cls.partner = cls.env["res.partner"].create(
{
"name": "Test Partner",
"fax": "1234567890",
}
)

def test_qweb_contact_field_fax_displayed(self):
Contact = self.env["ir.qweb.field.contact"]
result = Contact.value_to_html(self.partner, {"fields": ["name", "fax"]})
self.assertIn("1234567890", result)
self.assertIn('itemprop="faxNumber"', result)

def test_qweb_contact_field_fax_hidden_if_not_set(self):
self.partner.fax = None
Contact = self.env["ir.qweb.field.contact"]
result = Contact.value_to_html(self.partner, {"fields": ["name", "fax"]})
self.assertNotIn('itemprop="faxNumber"', result)

def test_qweb_contact_field_fax_hidden_by_default(self):
Contact = self.env["ir.qweb.field.contact"]
result = Contact.value_to_html(self.partner, {})
self.assertNotIn("1234567890", result)
self.assertNotIn('itemprop="faxNumber"', result)
26 changes: 26 additions & 0 deletions partner_fax/views/templates.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
Copyright 2024 Camptocamp SA (https://www.camptocamp.com).
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
-->
<odoo>

<template id="contact" inherit_id="base.contact">
<div t-if="mobile and 'mobile' in fields" position="after">
<div
class="d-flex align-items-center gap-1"
t-if="object.fax and 'fax' in fields"
>
<i
t-if="not options.get('no_marker') or options.get('phone_icons')"
class='fa fa-fax fa-fw'
role="img"
aria-label="Fax"
title="Fax"
/>
<span class="o_force_ltr" itemprop="faxNumber" t-esc="object.fax" />
</div>
</div>
</template>

</odoo>

0 comments on commit 571bdcc

Please sign in to comment.