-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by sebastienbeau
- Loading branch information
Showing
2 changed files
with
47 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
# @author Sébastien BEAU <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo.exceptions import AccessError | ||
from odoo.exceptions import AccessError, UserError | ||
|
||
from .common import CommonCase | ||
|
||
|
@@ -67,7 +67,7 @@ def test_create_address(self): | |
# no email, verify defaults | ||
params = dict(self.address_params, parent_id=self.partner.id) | ||
# type defaults to `other` | ||
expected = dict(params, type="other") | ||
expected = dict(params) | ||
self._test_create_address(params, expected) | ||
# pass email and type | ||
params = dict(params, email="[email protected]", type="invoice") | ||
|
@@ -79,6 +79,31 @@ def _test_update_address(self, address_id, params, expected): | |
address = self.env["res.partner"].browse(address_id) | ||
self.check_data(address, expected) | ||
|
||
def test_add_address_invoice(self): | ||
# Create an invoice address with wrong type | ||
# Check raise | ||
# Create an invoice address with invoice type | ||
# Check data | ||
self.address_params.update({"type": "wrong"}) | ||
address_ids = [ | ||
address["id"] for address in self.address_service.search()["data"] | ||
] | ||
with self.assertRaises(UserError): | ||
self.address_service.dispatch( | ||
"create", params=self.address_params | ||
)["data"] | ||
self.address_params.update({"type": "invoice"}) | ||
address_list = self.address_service.dispatch( | ||
"create", params=self.address_params | ||
)["data"] | ||
for address in address_list: | ||
if address["id"] not in address_ids: | ||
created_address = address | ||
self.assertIsNotNone(created_address) | ||
address = self.env["res.partner"].browse(created_address["id"]) | ||
self.assertEqual(address.parent_id, self.partner) | ||
self.check_data(address, self.address_params) | ||
|
||
def test_update_address(self): | ||
params = dict(self.address_params, parent_id=self.partner.id) | ||
expected = dict(params) | ||
|
@@ -104,6 +129,18 @@ def test_read_address_address(self): | |
expected_ids = {self.address.id, self.address_2.id} | ||
self.assertEqual(ids, expected_ids) | ||
|
||
def test_read_address_invoice(self): | ||
# Create an invoice address | ||
# Search it | ||
self.address_params.update({"type": "invoice"}) | ||
self.address_service.dispatch("create", params=self.address_params)[ | ||
"data" | ||
] | ||
res = self.address_service.dispatch( | ||
"search", params={"scope": {"type": "invoice"}} | ||
)["data"] | ||
self.assertEqual(len(res), 1) | ||
|
||
def test_read_address_all(self): | ||
res = self.address_service.dispatch("search", params={})["data"] | ||
self.assertEqual(len(res), 3) | ||
|