Skip to content

Commit 5ebfd41

Browse files
committed
[MIG] res_company_search_view: Migration to 19.0
1 parent c157989 commit 5ebfd41

6 files changed

Lines changed: 114 additions & 26 deletions

File tree

res_company_search_view/README.rst

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
.. image:: https://odoo-community.org/readme-banner-image
2+
:target: https://odoo-community.org/get-involved?utm_source=readme
3+
:alt: Odoo Community Association
4+
15
=====================
26
Company - Search View
37
=====================
@@ -13,17 +17,17 @@ Company - Search View
1317
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
1418
:target: https://odoo-community.org/page/development-status
1519
:alt: Beta
16-
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
20+
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
1721
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
1822
:alt: License: AGPL-3
1923
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmulti--company-lightgray.png?logo=github
20-
:target: https://github.com/OCA/multi-company/tree/18.0/res_company_search_view
24+
:target: https://github.com/OCA/multi-company/tree/19.0/res_company_search_view
2125
:alt: OCA/multi-company
2226
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23-
:target: https://translation.odoo-community.org/projects/multi-company-18-0/multi-company-18-0-res_company_search_view
27+
:target: https://translation.odoo-community.org/projects/multi-company-19-0/multi-company-19-0-res_company_search_view
2428
:alt: Translate me on Weblate
2529
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26-
:target: https://runboat.odoo-community.org/builds?repo=OCA/multi-company&target_branch=18.0
30+
:target: https://runboat.odoo-community.org/builds?repo=OCA/multi-company&target_branch=19.0
2731
:alt: Try me on Runboat
2832

2933
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -46,7 +50,7 @@ Bug Tracker
4650
Bugs are tracked on `GitHub Issues <https://github.com/OCA/multi-company/issues>`_.
4751
In case of trouble, please check there if your issue has already been reported.
4852
If you spotted it first, help us to smash it by providing a detailed and welcomed
49-
`feedback <https://github.com/OCA/multi-company/issues/new?body=module:%20res_company_search_view%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
53+
`feedback <https://github.com/OCA/multi-company/issues/new?body=module:%20res_company_search_view%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
5054

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

@@ -61,10 +65,10 @@ Authors
6165
Contributors
6266
------------
6367

64-
- Sylvain LE GAL <https://twitter.com/legalsylvain>
65-
- `Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>`__
68+
- Sylvain LE GAL <https://twitter.com/legalsylvain>
69+
- `Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>`__
6670

67-
- Bhavesh Heliconia
71+
- Bhavesh Heliconia
6872

6973
Maintainers
7074
-----------
@@ -87,6 +91,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
8791

8892
|maintainer-legalsylvain|
8993

90-
This module is part of the `OCA/multi-company <https://github.com/OCA/multi-company/tree/18.0/res_company_search_view>`_ project on GitHub.
94+
This module is part of the `OCA/multi-company <https://github.com/OCA/multi-company/tree/19.0/res_company_search_view>`_ project on GitHub.
9195

9296
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

res_company_search_view/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
{
66
"name": "Company - Search View",
77
"summary": "Add a search view for company model",
8-
"version": "18.0.1.0.0",
8+
"version": "19.0.1.0.0",
99
"category": "Tools",
1010
"author": "GRAP, Odoo Community Association (OCA)",
1111
"maintainers": ["legalsylvain"],

res_company_search_view/static/description/index.html

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
55
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
6-
<title>Company - Search View</title>
6+
<title>README.rst</title>
77
<style type="text/css">
88

99
/*
@@ -360,16 +360,21 @@
360360
</style>
361361
</head>
362362
<body>
363-
<div class="document" id="company-search-view">
364-
<h1 class="title">Company - Search View</h1>
363+
<div class="document">
365364

365+
366+
<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
367+
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
368+
</a>
369+
<div class="section" id="company-search-view">
370+
<h1>Company - Search View</h1>
366371
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
367372
!! This file is generated by oca-gen-addon-readme !!
368373
!! changes will be overwritten. !!
369374
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
370375
!! source digest: sha256:fca2081f254cc0a90137ca9521185e86986cb1c4d91cf03329ce91c26fc24dfe
371376
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
372-
<p><a class="reference external image-reference" 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 image-reference" 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 image-reference" href="https://github.com/OCA/multi-company/tree/18.0/res_company_search_view"><img alt="OCA/multi-company" src="https://img.shields.io/badge/github-OCA%2Fmulti--company-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/multi-company-18-0/multi-company-18-0-res_company_search_view"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/multi-company&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
377+
<p><a class="reference external image-reference" 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 image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/multi-company/tree/19.0/res_company_search_view"><img alt="OCA/multi-company" src="https://img.shields.io/badge/github-OCA%2Fmulti--company-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/multi-company-19-0/multi-company-19-0-res_company_search_view"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/multi-company&amp;target_branch=19.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
373378
<p>This module simply add a search view for the <tt class="docutils literal">res.company</tt> model.</p>
374379
<p>It is used to be extended in other modules.</p>
375380
<p>Technically, it is an adaptation of the <tt class="docutils literal">res.partner</tt> search view.
@@ -387,23 +392,23 @@ <h1 class="title">Company - Search View</h1>
387392
</ul>
388393
</div>
389394
<div class="section" id="bug-tracker">
390-
<h1><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h1>
395+
<h2><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h2>
391396
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/multi-company/issues">GitHub Issues</a>.
392397
In case of trouble, please check there if your issue has already been reported.
393398
If you spotted it first, help us to smash it by providing a detailed and welcomed
394-
<a class="reference external" href="https://github.com/OCA/multi-company/issues/new?body=module:%20res_company_search_view%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
399+
<a class="reference external" href="https://github.com/OCA/multi-company/issues/new?body=module:%20res_company_search_view%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
395400
<p>Do not contact contributors directly about support or help with technical issues.</p>
396401
</div>
397402
<div class="section" id="credits">
398-
<h1><a class="toc-backref" href="#toc-entry-2">Credits</a></h1>
403+
<h2><a class="toc-backref" href="#toc-entry-2">Credits</a></h2>
399404
<div class="section" id="authors">
400-
<h2><a class="toc-backref" href="#toc-entry-3">Authors</a></h2>
405+
<h3><a class="toc-backref" href="#toc-entry-3">Authors</a></h3>
401406
<ul class="simple">
402407
<li>GRAP</li>
403408
</ul>
404409
</div>
405410
<div class="section" id="contributors">
406-
<h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
411+
<h3><a class="toc-backref" href="#toc-entry-4">Contributors</a></h3>
407412
<ul class="simple">
408413
<li>Sylvain LE GAL &lt;<a class="reference external" href="https://twitter.com/legalsylvain">https://twitter.com/legalsylvain</a>&gt;</li>
409414
<li><a class="reference external" href="https://www.heliconia.io">Heliconia Solutions Pvt. Ltd.</a><ul>
@@ -413,7 +418,7 @@ <h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
413418
</ul>
414419
</div>
415420
<div class="section" id="maintainers">
416-
<h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
421+
<h3><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h3>
417422
<p>This module is maintained by the OCA.</p>
418423
<a class="reference external image-reference" href="https://odoo-community.org">
419424
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
@@ -423,10 +428,11 @@ <h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
423428
promote its widespread use.</p>
424429
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
425430
<p><a class="reference external image-reference" href="https://github.com/legalsylvain"><img alt="legalsylvain" src="https://github.com/legalsylvain.png?size=40px" /></a></p>
426-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/multi-company/tree/18.0/res_company_search_view">OCA/multi-company</a> project on GitHub.</p>
431+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/multi-company/tree/19.0/res_company_search_view">OCA/multi-company</a> project on GitHub.</p>
427432
<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>
428433
</div>
429434
</div>
430435
</div>
436+
</div>
431437
</body>
432438
</html>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import test_res_company_search_view
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
from lxml import etree
2+
3+
from odoo.tests import TransactionCase, tagged
4+
from odoo.tools.safe_eval import safe_eval
5+
6+
7+
@tagged("post_install", "-at_install")
8+
class TestResCompanySearchView(TransactionCase):
9+
@classmethod
10+
def setUpClass(cls):
11+
super().setUpClass()
12+
cls.Company = cls.env["res.company"]
13+
cls.company_alpha = cls.Company.create(
14+
{
15+
"name": "Alpha Logistics",
16+
"vat": "BE123456789",
17+
"email": "info@alpha.com",
18+
"phone": "0123456789",
19+
}
20+
)
21+
cls.company_beta = cls.Company.create(
22+
{
23+
"name": "Beta Transport",
24+
"vat": "BE987654321",
25+
"email": "contact@beta.com",
26+
"phone": "0470123456",
27+
}
28+
)
29+
30+
# Load your search view
31+
cls.view = cls.env.ref("res_company_search_view.view_res_company_search")
32+
33+
def _get_field_domain(self, field_name, search_value):
34+
"""Helper: evaluate filter_domain for a <field> node."""
35+
arch = etree.fromstring(self.view.arch_db)
36+
node = arch.xpath(f"//field[@name='{field_name}']")
37+
if not node:
38+
self.fail(f"No <field name='{field_name}'> found in search view.")
39+
filter_domain = node[0].get("filter_domain")
40+
return safe_eval(filter_domain, {"self": search_value})
41+
42+
def _get_filter_domain(self, filter_name):
43+
"""Helper: evaluate domain for a <filter> node."""
44+
arch = etree.fromstring(self.view.arch_db)
45+
node = arch.xpath(f"//filter[@name='{filter_name}']")
46+
if not node:
47+
self.fail(f"No <filter name='{filter_name}'> found in search view.")
48+
domain = node[0].get("domain")
49+
return safe_eval(domain or "[]")
50+
51+
# ---------- Tests ----------
52+
53+
def test_name_filter_domain(self):
54+
"""Search by name/vat/company_registry."""
55+
domain = self._get_field_domain("name", "Beta")
56+
result = self.Company.search(domain)
57+
self.assertIn(self.company_beta, result)
58+
self.assertNotIn(self.company_alpha, result)
59+
60+
def test_email_filter_domain(self):
61+
"""Search by email."""
62+
domain = self._get_field_domain("email", "alpha.com")
63+
result = self.Company.search(domain)
64+
self.assertIn(self.company_alpha, result)
65+
self.assertNotIn(self.company_beta, result)
66+
67+
def test_phone_filter_domain(self):
68+
"""Search by phone or mobile."""
69+
domain = self._get_field_domain("phone", "0470")
70+
result = self.Company.search(domain)
71+
self.assertIn(self.company_beta, result)
72+
self.assertNotIn(self.company_alpha, result)
73+
74+
def test_archived_filter(self):
75+
"""Ensure Archived filter domain works."""
76+
self.company_beta.active = False
77+
domain = self._get_filter_domain("inactive")
78+
result = self.Company.search(domain)
79+
self.assertIn(self.company_beta, result)
80+
self.assertNotIn(self.company_alpha, result)

res_company_search_view/views/view_res_company.xml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
1717
('company_registry', 'ilike', self)]"
1818
/>
1919
<field name="email" filter_domain="[('email', 'ilike', self)]" />
20-
<field
21-
name="phone"
22-
filter_domain="['|', ('phone', 'ilike', self), ('mobile', 'ilike', self)]"
23-
/>
20+
<field name="phone" filter_domain="[('phone', 'ilike', self)]" />
2421
<field name="parent_id" operator="child_of" />
2522
<separator />
2623
<filter
@@ -29,7 +26,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
2926
domain="[('active', '=', False)]"
3027
/>
3128
<separator />
32-
<group expand="0" name="group_by" string="Group By">
29+
<group name="group_by">
3330
<filter
3431
name="group_country"
3532
string="Country"

0 commit comments

Comments
 (0)