Skip to content

Commit

Permalink
TA#66798 [MIG] partner_autocomplete_disable (#151)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Majda EL MARIOULI <[email protected]>
  • Loading branch information
rivo2302 and majouda authored Aug 21, 2024
1 parent 91bad3f commit a3239c3
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 29 deletions.
2 changes: 1 addition & 1 deletion partner_autocomplete_disable/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# © 2022 Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# © 2024 - Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from . import models
3 changes: 2 additions & 1 deletion partner_autocomplete_disable/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{
"name": "Partner Autocomplete Disable",
"version": "1.1.0",
"version": "16.0.2.1.0",
"author": "Numigi",
"maintainer": "Numigi",
"license": "LGPL-3",
Expand All @@ -14,6 +14,7 @@
],
"data": [
"data/views_data.xml",
"views/res_config_settings_views.xml",
],
"installable": True,
}
4 changes: 2 additions & 2 deletions partner_autocomplete_disable/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# © 2022 - Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# © 2024 - Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from . import res_partner
from . import iap_autocomplete_api
13 changes: 13 additions & 0 deletions partner_autocomplete_disable/models/iap_autocomplete_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# © 2024 - Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).


from odoo import api, models


class IapAutocompleteEnrichAPI(models.AbstractModel):
_inherit = "iap.autocomplete.api"

@api.model
def _contact_iap(self, local_endpoint, action, params, timeout=15):
return []
12 changes: 0 additions & 12 deletions partner_autocomplete_disable/models/res_partner.py

This file was deleted.

4 changes: 3 additions & 1 deletion partner_autocomplete_disable/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# © 2022 - Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# © 2024 - Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from . import test_res_partner
17 changes: 5 additions & 12 deletions partner_autocomplete_disable/tests/test_res_partner.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# © 2022 - Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# © 2024 - Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from ddt import ddt, data
Expand All @@ -12,13 +12,6 @@ def setUp(self):
super().setUp()
self.partner = self.env.ref("base.res_partner_1")

@data("konvergo", "odoo", "something", "google.com", "")
def test_rpc_remote_api(self, query):
with mock.patch("odoo.addons.iap.jsonrpc") as mocked:
res = self.partner._rpc_remote_api("search", {"query": query})
assert mocked.call_count == 0
assert res == ({}, False)

@data("konvergo", "odoo", "something", "google.com", "")
def test_autocomplete(self, query):
with mock.patch("odoo.addons.iap.jsonrpc") as mocked:
Expand All @@ -29,7 +22,7 @@ def test_autocomplete(self, query):
def test_enrich_company(self, name):
with mock.patch("odoo.addons.iap.jsonrpc") as mocked:
res = self.partner.enrich_company(name, 123, "U12345678")
assert res['error']
assert res == {}
assert mocked.call_count == 0

@data(
Expand Down Expand Up @@ -62,9 +55,9 @@ def test_whenStartSync_thenPatchedMethodIsCalled(self):
"""
module_memory_address = (
"odoo.addons.partner_autocomplete_disable"
".models.res_partner.ResPartnerAutocompleteDisable"
".models.iap_autocomplete_api.IapAutocompleteEnrichAPI"
)
with mock.patch(".".join([module_memory_address, "_rpc_remote_api"])) as mocked:
with mock.patch(".".join([module_memory_address, "_contact_iap"])) as mocked:
autocomplete_module_memory_address = (
"odoo.addons.partner_autocomplete.models.res_partner.ResPartner"
)
Expand All @@ -74,7 +67,7 @@ def test_whenStartSync_thenPatchedMethodIsCalled(self):
)) as sync:
sync.return_value = True
self.autocomplete_sync.start_sync()
assert mocked.call_count == 0
assert mocked.call_count == 1

def test_whenStartSync_noDataAreSent(self):
with mock.patch("odoo.addons.iap.jsonrpc") as mocked:
Expand Down
13 changes: 13 additions & 0 deletions partner_autocomplete_disable/views/res_config_settings_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="name">res.config.settings.view.form.inherit.partner.autcomplete</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="base_setup.res_config_settings_view_form"/>
<field name="arch" type="xml">
<xpath expr="//div[@name='contacts_setting_container']/div[2]" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
</field>
</record>
</odoo>

0 comments on commit a3239c3

Please sign in to comment.