-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] fieldservice_portal: Migation to 16.0
- Loading branch information
Showing
9 changed files
with
187 additions
and
30 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
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,13 @@ | ||
/** @odoo-module */ | ||
|
||
import "portal.portal"; // Force dependencies | ||
import publicWidget from "web.public.widget"; | ||
|
||
publicWidget.registry.PortalHomeCounters.include({ | ||
/** | ||
* @override | ||
*/ | ||
_getCountersAlwaysDisplayed() { | ||
return this._super(...arguments).concat(["fsm_order_count"]); | ||
}, | ||
}); |
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 @@ | ||
from . import test_portal |
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,136 @@ | ||
from odoo.exceptions import AccessError | ||
from odoo.http import Request | ||
from odoo.tests.common import HttpCase, TransactionCase, tagged | ||
|
||
|
||
@tagged("post_install", "-at_install") | ||
class TestUsersHttp(HttpCase, TransactionCase): | ||
def test_fsm_order_portal(self): | ||
# Accessing work order of the portal user through route APIs available | ||
login = "portal" | ||
self.authenticate(login, login) | ||
response = self.url_open( | ||
"/my/workorders", | ||
data={ | ||
"validation": login, | ||
"password": login, | ||
"csrf_token": Request.csrf_token(self), | ||
}, | ||
) | ||
|
||
# Check successful response from API | ||
self.assertEqual(response.status_code, 200) | ||
|
||
login = "demo" | ||
self.authenticate(login, login) | ||
response = self.url_open( | ||
"/my/workorders", | ||
data={ | ||
"validation": login, | ||
"password": login, | ||
"csrf_token": Request.csrf_token(self), | ||
}, | ||
) | ||
|
||
# Check Forbidden response from API | ||
self.assertEqual(response.status_code, 403) | ||
|
||
def test_fsm_order_access(self): | ||
order_id = self.env["fsm.order"].search([])[0].id | ||
login = "portal" | ||
self.authenticate(login, login) | ||
response = self.url_open( | ||
"/my/workorder/" + str(order_id), | ||
data={ | ||
"validation": login, | ||
"password": login, | ||
"csrf_token": Request.csrf_token(self), | ||
}, | ||
) | ||
self.assertEqual(response.status_code, 200) | ||
|
||
def test_fsm_order_access_denied(self): | ||
# create a Res Partner to be converted to FSM Location/Person | ||
test_loc_partner = self.env["res.partner"].create( | ||
{"name": "Test Loc Partner", "phone": "ABC", "email": "tlp@email.com"} | ||
) | ||
# create FSM Location and assign it to different user other than Portal User | ||
test_location = self.env["fsm.location"].create( | ||
{ | ||
"name": "Test Location No Portal User", | ||
"phone": "123", | ||
"email": "tp@email.com", | ||
"customer_id": test_loc_partner.id, | ||
"partner_id": test_loc_partner.id, | ||
"owner_id": test_loc_partner.id, | ||
} | ||
) | ||
order = self.env["fsm.order"].create( | ||
{ | ||
"location_id": test_location.id, | ||
} | ||
) | ||
|
||
# Trying to access workorder which is not | ||
# assigned to Portal User to check access error | ||
login = "portal" | ||
self.authenticate(login, login) | ||
self.url_open( | ||
"/my/workorder/" + str(order.id), | ||
data={ | ||
"validation": login, | ||
"password": login, | ||
"csrf_token": Request.csrf_token(self), | ||
}, | ||
) | ||
self.assertRaises( | ||
AccessError, msg="Access Denied by record rules for operation: read" | ||
) | ||
|
||
def test_fsm_order_kw_usage(self): | ||
order_id = self.env["fsm.order"].search([])[0].id | ||
# Trying to access workorder url | ||
# with query parameters | ||
login = "portal" | ||
self.authenticate(login, login) | ||
response = self.url_open( | ||
"/my/workorder/" + str(order_id) + "?success='success'", | ||
data={ | ||
"validation": login, | ||
"password": login, | ||
"csrf_token": Request.csrf_token(self), | ||
}, | ||
) | ||
self.assertEqual(response.status_code, 200) | ||
|
||
def test_fsm_no_workorder_present(self): | ||
# Trying to filter workorders based on filter | ||
login = "portal" | ||
self.authenticate(login, login) | ||
response = self.url_open( | ||
"/my/workorders?groupby=none&filterby=Completed&page=1&search_in=&search=", | ||
data={ | ||
"validation": login, | ||
"password": login, | ||
"csrf_token": Request.csrf_token(self), | ||
}, | ||
) | ||
self.assertEqual(response.status_code, 200) | ||
self.assertNotIn("<tbody>", response.text) | ||
self.assertIn("<p>There are no Work Orders in your account.</p>", response.text) | ||
|
||
def test_fsm_order_filter_usage(self): | ||
# Trying to filter workorders based on filter, group and sort | ||
login = "portal" | ||
self.authenticate(login, login) | ||
response = self.url_open( | ||
"/my/workorders?groupby=stage_id&filterby=New&sortby=location", | ||
data={ | ||
"validation": login, | ||
"password": login, | ||
"csrf_token": Request.csrf_token(self), | ||
}, | ||
) | ||
self.assertEqual(response.status_code, 200) | ||
self.assertIn("<tbody>", response.text) | ||
self.assertIn("Demo Order", response.text) |
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