-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TA#66798 [16.0] [MIG] partner_autocomplete_disable (#146)
* TA#66798 [16.0][MIG] partner_autocomplete_disable --------- Co-authored-by: majouda <[email protected]>
- Loading branch information
1 parent
2837d10
commit a77d83c
Showing
11 changed files
with
152 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Partner Autocomplete Disable | ||
============================ | ||
Disable the autocompletion in partners and companies. | ||
|
||
Contributors | ||
------------ | ||
* Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
|
||
More information | ||
---------------- | ||
* Meet us at https://bit.ly/numigi-com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# © 2022 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# © 2022 Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
{ | ||
"name": "Partner Autocomplete Disable", | ||
"version": "1.1.0", | ||
"author": "Numigi", | ||
"maintainer": "Numigi", | ||
"license": "LGPL-3", | ||
"category": "Other", | ||
"summary": "Disable the Partner autocomplete feature", | ||
"depends": [ | ||
"partner_autocomplete", | ||
], | ||
"data": [ | ||
"data/views_data.xml", | ||
], | ||
"installable": True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<odoo> | ||
<record id="partner_autocomplete.view_res_partner_form_inherit_partner_autocomplete" model="ir.ui.view"> | ||
<field name="active" eval="False"/> | ||
</record> | ||
<record id="partner_autocomplete.view_partner_simple_form_inherit_partner_autocomplete" model="ir.ui.view"> | ||
<field name="active" eval="False"/> | ||
</record> | ||
<record id="partner_autocomplete.view_company_form_inherit_partner_autocomplete" model="ir.ui.view"> | ||
<field name="active" eval="False"/> | ||
</record> | ||
<record id="partner_autocomplete.ir_cron_partner_autocomplete" model="ir.cron"> | ||
<field name="active" eval="False"/> | ||
</record> | ||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# © 2022 - 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# © 2022 - 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 ResPartnerAutocompleteDisable(models.Model): | ||
_inherit = "res.partner" | ||
|
||
@api.model | ||
def _rpc_remote_api(self, *args, **kwargs): | ||
return {}, False |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# © 2022 - Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# © 2022 - 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 | ||
from unittest import mock | ||
from odoo.tests import common | ||
|
||
|
||
@ddt | ||
class TestResPartner(common.TransactionCase): | ||
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: | ||
assert self.partner.autocomplete(query) == [] | ||
assert mocked.call_count == 0 | ||
|
||
@data("konvergo", "odoo", "something", "google.com", "") | ||
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 mocked.call_count == 0 | ||
|
||
@data( | ||
"U12345678", | ||
"1234567890", | ||
"12345678901", | ||
"12345678X", | ||
"XX123456789", | ||
"" | ||
) | ||
def test_read_by_vat(self, vat): | ||
with mock.patch("odoo.addons.iap.jsonrpc") as mocked: | ||
assert self.partner.read_by_vat(vat) == [] | ||
assert mocked.call_count == 0 | ||
|
||
|
||
class TestResPartnerAutocompleteSync(common.TransactionCase): | ||
|
||
def setUp(self): | ||
super().setUp() | ||
self.partner = self.env.ref("base.res_partner_1") | ||
self.partner.vat = "XX123456789" | ||
self.autocomplete_sync = self.env["res.partner.autocomplete.sync"].create({ | ||
"partner_id": self.partner.id, | ||
"synched": False | ||
}) | ||
|
||
def test_whenStartSync_thenPatchedMethodIsCalled(self): | ||
""" make sure the targeted method is called during the process | ||
""" | ||
module_memory_address = ( | ||
"odoo.addons.partner_autocomplete_disable" | ||
".models.res_partner.ResPartnerAutocompleteDisable" | ||
) | ||
with mock.patch(".".join([module_memory_address, "_rpc_remote_api"])) as mocked: | ||
autocomplete_module_memory_address = ( | ||
"odoo.addons.partner_autocomplete.models.res_partner.ResPartner" | ||
) | ||
mocked.return_value = {}, False | ||
with mock.patch(".".join( | ||
[autocomplete_module_memory_address, "_is_vat_syncable"] | ||
)) as sync: | ||
sync.return_value = True | ||
self.autocomplete_sync.start_sync() | ||
assert mocked.call_count == 0 | ||
|
||
def test_whenStartSync_noDataAreSent(self): | ||
with mock.patch("odoo.addons.iap.jsonrpc") as mocked: | ||
self.autocomplete_sync.start_sync() | ||
assert mocked.call_count == 0 |