From 5d5d6beafcde225eb72bd993308a7467e3596fca Mon Sep 17 00:00:00 2001 From: Alessio Renda Date: Mon, 11 Dec 2023 12:40:22 +0100 Subject: [PATCH 1/3] [ADD] fieldservice_portal --- fieldservice_portal/README.rst | 90 ++++ fieldservice_portal/__init__.py | 1 + fieldservice_portal/__manifest__.py | 28 ++ fieldservice_portal/controllers/__init__.py | 1 + .../controllers/fsm_order_portal.py | 211 +++++++++ .../demo/fsm_location_demo.xml | 6 + fieldservice_portal/demo/fsm_order_demo.xml | 8 + fieldservice_portal/readme/CONTRIBUTORS.rst | 3 + fieldservice_portal/readme/DESCRIPTION.rst | 2 + .../security/ir.model.access.csv | 4 + .../security/portal_security.xml | 36 ++ .../static/description/index.html | 430 ++++++++++++++++++ .../views/fsm_order_template.xml | 148 ++++++ fieldservice_portal/views/portal_template.xml | 40 ++ 14 files changed, 1008 insertions(+) create mode 100644 fieldservice_portal/README.rst create mode 100644 fieldservice_portal/__init__.py create mode 100644 fieldservice_portal/__manifest__.py create mode 100644 fieldservice_portal/controllers/__init__.py create mode 100644 fieldservice_portal/controllers/fsm_order_portal.py create mode 100644 fieldservice_portal/demo/fsm_location_demo.xml create mode 100644 fieldservice_portal/demo/fsm_order_demo.xml create mode 100644 fieldservice_portal/readme/CONTRIBUTORS.rst create mode 100644 fieldservice_portal/readme/DESCRIPTION.rst create mode 100644 fieldservice_portal/security/ir.model.access.csv create mode 100644 fieldservice_portal/security/portal_security.xml create mode 100644 fieldservice_portal/static/description/index.html create mode 100644 fieldservice_portal/views/fsm_order_template.xml create mode 100644 fieldservice_portal/views/portal_template.xml diff --git a/fieldservice_portal/README.rst b/fieldservice_portal/README.rst new file mode 100644 index 0000000000..1ac4c41a8f --- /dev/null +++ b/fieldservice_portal/README.rst @@ -0,0 +1,90 @@ +============================ +Field Service - Order Portal +============================ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:bfddb8307746f6f3179ded15fd2c7b9a6622c6e21d24ae73c9aece10a7f455f6 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Ffield--service-lightgray.png?logo=github + :target: https://github.com/OCA/field-service/tree/14.0/fieldservice_portal + :alt: OCA/field-service +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/field-service-14-0/field-service-14-0-fieldservice_portal + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/field-service&target_branch=14.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Bridge module between fieldservice and portal that allows portal users +to monitor work orders related to their locations. + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* PyTech SRL + +Contributors +~~~~~~~~~~~~ + +* `PyTech SRL `_: + + * Alessio Renda + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +.. |maintainer-aleuffre| image:: https://github.com/aleuffre.png?size=40px + :target: https://github.com/aleuffre + :alt: aleuffre +.. |maintainer-renda-dev| image:: https://github.com/renda-dev.png?size=40px + :target: https://github.com/renda-dev + :alt: renda-dev + +Current `maintainers `__: + +|maintainer-aleuffre| |maintainer-renda-dev| + +This module is part of the `OCA/field-service `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/fieldservice_portal/__init__.py b/fieldservice_portal/__init__.py new file mode 100644 index 0000000000..e046e49fbe --- /dev/null +++ b/fieldservice_portal/__init__.py @@ -0,0 +1 @@ +from . import controllers diff --git a/fieldservice_portal/__manifest__.py b/fieldservice_portal/__manifest__.py new file mode 100644 index 0000000000..07786fde2d --- /dev/null +++ b/fieldservice_portal/__manifest__.py @@ -0,0 +1,28 @@ +{ + "name": "Field Service - Order Portal", + "version": "14.0.1.0.0", + "summary": """ + Bridge module between fieldservice and portal. + """, + "depends": [ + "fieldservice", + "portal", + ], + "author": "PyTech SRL, Odoo Community Association (OCA)", + "maintainers": ["aleuffre", "renda-dev"], + "website": "https://github.com/OCA/field-service", + "category": "Field Service", + "license": "AGPL-3", + "data": [ + "security/ir.model.access.csv", + "security/portal_security.xml", + "views/fsm_order_template.xml", + "views/portal_template.xml", + ], + "demo": [ + "demo/fsm_location_demo.xml", + "demo/fsm_order_demo.xml", + ], + "installable": True, + "application": False, +} diff --git a/fieldservice_portal/controllers/__init__.py b/fieldservice_portal/controllers/__init__.py new file mode 100644 index 0000000000..d09bc16471 --- /dev/null +++ b/fieldservice_portal/controllers/__init__.py @@ -0,0 +1 @@ +from . import fsm_order_portal diff --git a/fieldservice_portal/controllers/fsm_order_portal.py b/fieldservice_portal/controllers/fsm_order_portal.py new file mode 100644 index 0000000000..37ace8ab8d --- /dev/null +++ b/fieldservice_portal/controllers/fsm_order_portal.py @@ -0,0 +1,211 @@ +from collections import OrderedDict +from operator import itemgetter + +from odoo import _, http +from odoo.exceptions import AccessError +from odoo.http import request +from odoo.osv.expression import OR +from odoo.tools import groupby as groupbyelem + +from odoo.addons.portal.controllers.portal import CustomerPortal, pager as portal_pager + + +class CustomerPortal(CustomerPortal): + def _prepare_portal_layout_values(self): + values = super()._prepare_portal_layout_values() + fsm_order_count = ( + request.env["fsm.order"].search_count([]) + if request.env["fsm.order"].check_access_rights( + "read", raise_exception=False + ) + else 0 + ) + values["fsm_order_count"] = fsm_order_count + return values + + def _fsm_order_check_access(self, order_id): + order = request.env["fsm.order"].browse([order_id]) + + try: + order.check_access_rights("read") + order.check_access_rule("read") + except AccessError: + raise + return order.sudo() + + def fsm_order_get_page_view_values(self, order, **kwargs): + values = { + "page_name": "fsm_order", + "order": order, + } + + if kwargs.get("error"): + values["error"] = kwargs["error"] + if kwargs.get("warning"): + values["warning"] = kwargs["warning"] + if kwargs.get("success"): + values["success"] = kwargs["success"] + + return values + + @http.route( + ["/my/workorders", "/my/workorders/page/"], + type="http", + auth="user", + website=True, + ) + def portal_my_fsm_orders( + self, + page=1, + date_begin=None, + date_end=None, + sortby=None, + filterby=None, + groupby=None, + search=None, + search_in="all", + **kw + ): + values = self._prepare_portal_layout_values() + FsmOrder = request.env["fsm.order"] + domain = [] + + searchbar_sortings = { + "date": {"label": _("Newest"), "order": "request_early desc"}, + "name": {"label": _("Name"), "order": "name"}, + "stage": {"label": _("Stage"), "order": "stage_id"}, + "location": {"label": _("Location"), "order": "location_id"}, + "type": {"label": _("Type"), "order": "type"}, + } + + searchbar_groupby = { + "none": {"input": "none", "label": _("None")}, + "location_id": {"input": "location", "label": _("Location")}, + "ticket_id": {"input": "ticket", "label": _("Ticket")}, + "stage_id": {"input": "stage", "label": _("Stage")}, + "type": {"input": "type", "label": _("Type")}, + } + + # search input (text) + searchbar_inputs = OrderedDict( + ( + ("all", {"input": "all", "label": _("Search in All")}), + ("name", {"input": "name", "label": _("Search in WO Number")}), + ( + "description", + { + "input": "description", + "label": _("Search in Description"), + }, + ), + ( + "location_id.name", + { + "input": "location", + "label": _("Search in Location Numbers"), + }, + ), + ) + ) + + if search and search_in: + search_domain = [] + for search_property in [ + k + for (k, v) in searchbar_inputs.items() + if search_in in (v["input"], "all") and k != "all" + ]: + search_domain = OR( + [search_domain, [(search_property, "ilike", search)]] + ) + domain += search_domain + + # search filters (by stage) + searchbar_filters = OrderedDict( + ( + str(stage.name), + { + "label": stage.name, + "domain": [("stage_id", "=", stage.id)], + }, + ) + for stage in request.env["fsm.stage"].search([("stage_type", "=", "order")]) + ) + searchbar_filters.update( + { + "all": {"label": _("All"), "domain": []}, + "open": {"label": _("Open"), "domain": [("is_closed", "=", False)]}, + } + ) + + # default group by value + if not groupby: + groupby = "location_id" + # default sort by order + if not sortby: + sortby = "date" + order = searchbar_sortings[sortby]["order"] + # default filter by value + if not filterby: + filterby = "open" + domain += searchbar_filters[filterby]["domain"] + + # count for pager + fsm_order_count = FsmOrder.search_count(domain) + # pager + pager = portal_pager( + url="/my/workorders", + url_args={}, + total=fsm_order_count, + page=page, + step=self._items_per_page, + ) + # content according to pager and archive selected + fsm_orders = FsmOrder.search( + domain, + order=order, + limit=self._items_per_page, + offset=pager["offset"], + ) + + if groupby == "none": + grouped_orders = [fsm_orders] if fsm_orders else [] + else: + grouped_orders = [ + FsmOrder.concat(*g) + for k, g in groupbyelem(fsm_orders, itemgetter(groupby)) + ] + + values.update( + { + "date": date_begin, + "grouped_orders": grouped_orders, + "page_name": "fsm_order", + "pager": pager, + "default_url": "/my/workorders", + "searchbar_sortings": searchbar_sortings, + "searchbar_groupby": searchbar_groupby, + "searchbar_inputs": searchbar_inputs, + "search_in": search_in, + "sortby": sortby, + "groupby": groupby, + "searchbar_filters": searchbar_filters, + "filterby": filterby, + } + ) + return request.render("fieldservice_portal.portal_my_fsm_orders", values) + + @http.route( + ["/my/workorder/"], + type="http", + website=True, + ) + def portal_my_fsm_order(self, order_id=None, **kw): + try: + order_sudo = self._fsm_order_check_access(order_id) + except AccessError: + return request.redirect("/my") + values = self.fsm_order_get_page_view_values(order_sudo, **kw) + return request.render( + "fieldservice_portal.portal_fieldservice_order_page", values + ) diff --git a/fieldservice_portal/demo/fsm_location_demo.xml b/fieldservice_portal/demo/fsm_location_demo.xml new file mode 100644 index 0000000000..d2137b34d0 --- /dev/null +++ b/fieldservice_portal/demo/fsm_location_demo.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/fieldservice_portal/demo/fsm_order_demo.xml b/fieldservice_portal/demo/fsm_order_demo.xml new file mode 100644 index 0000000000..0bde574bd9 --- /dev/null +++ b/fieldservice_portal/demo/fsm_order_demo.xml @@ -0,0 +1,8 @@ + + + + Demo Order + Description for the new demo order + + + diff --git a/fieldservice_portal/readme/CONTRIBUTORS.rst b/fieldservice_portal/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..e4ec89c4ce --- /dev/null +++ b/fieldservice_portal/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `PyTech SRL `_: + + * Alessio Renda diff --git a/fieldservice_portal/readme/DESCRIPTION.rst b/fieldservice_portal/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..13440bbbf7 --- /dev/null +++ b/fieldservice_portal/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +Bridge module between fieldservice and portal that allows portal users +to monitor work orders related to their locations. diff --git a/fieldservice_portal/security/ir.model.access.csv b/fieldservice_portal/security/ir.model.access.csv new file mode 100644 index 0000000000..4161fb7bcf --- /dev/null +++ b/fieldservice_portal/security/ir.model.access.csv @@ -0,0 +1,4 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_fsm_order_portal,fieldservice.order.portal,fieldservice.model_fsm_order,base.group_portal,1,0,0,0 +access_fsm_stage_portal,fieldservice.stage.portal,fieldservice.model_fsm_stage,base.group_portal,1,0,0,0 +access_fsm_order_type_portal,fieldservice.order.type.portal,fieldservice.model_fsm_order_type,base.group_portal,1,0,0,0 diff --git a/fieldservice_portal/security/portal_security.xml b/fieldservice_portal/security/portal_security.xml new file mode 100644 index 0000000000..9e3dea0ccf --- /dev/null +++ b/fieldservice_portal/security/portal_security.xml @@ -0,0 +1,36 @@ + + + + + Portal Personal Orders + + ['|','|', + ('location_id.owner_id', 'child_of', [user.commercial_partner_id.id]), + ('location_id.contact_id', 'child_of', [user.commercial_partner_id.id]), + ('message_partner_ids','child_of',[user.commercial_partner_id.id])] + + + + + Portal Personal Locations + + ['|','|', + ('owner_id', 'child_of', [user.commercial_partner_id.id]), + ('contact_id', 'child_of', [user.commercial_partner_id.id]), + ('message_partner_ids','child_of',[user.commercial_partner_id.id])] + + + + + Portal Personal Locations + + ['&', + ('service_location_id', '!=', False), + '|','|', + ('service_location_id.owner_id', 'child_of', [user.commercial_partner_id.id]), + ('service_location_id.contact_id', 'child_of', [user.commercial_partner_id.id]), + ('service_location_id.message_partner_ids','child_of', [user.commercial_partner_id.id])] + + + + diff --git a/fieldservice_portal/static/description/index.html b/fieldservice_portal/static/description/index.html new file mode 100644 index 0000000000..91c7e0be7f --- /dev/null +++ b/fieldservice_portal/static/description/index.html @@ -0,0 +1,430 @@ + + + + + + +Field Service - Order Portal + + + +
+

Field Service - Order Portal

+ + +

Beta License: AGPL-3 OCA/field-service Translate me on Weblate Try me on Runboat

+

Bridge module between fieldservice and portal that allows portal users +to monitor work orders related to their locations.

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • PyTech SRL
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

Current maintainers:

+

aleuffre renda-dev

+

This module is part of the OCA/field-service project on GitHub.

+

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

+
+
+
+ + diff --git a/fieldservice_portal/views/fsm_order_template.xml b/fieldservice_portal/views/fsm_order_template.xml new file mode 100644 index 0000000000..7f58675f09 --- /dev/null +++ b/fieldservice_portal/views/fsm_order_template.xml @@ -0,0 +1,148 @@ + + + + + + + diff --git a/fieldservice_portal/views/portal_template.xml b/fieldservice_portal/views/portal_template.xml new file mode 100644 index 0000000000..3d1f23fe03 --- /dev/null +++ b/fieldservice_portal/views/portal_template.xml @@ -0,0 +1,40 @@ + + + + + + From 09eef2738afa249e8a22c1a4e8821183c197dc70 Mon Sep 17 00:00:00 2001 From: anusrinps96 Date: Tue, 15 Oct 2024 16:55:51 +0200 Subject: [PATCH 2/3] [IMP] fieldservice_portal: pre-commit stuff --- fieldservice_portal/README.rst | 14 +++++++------- fieldservice_portal/__manifest__.py | 2 +- .../static/description/index.html | 18 ++++++++++-------- .../odoo/addons/fieldservice_portal | 1 + setup/fieldservice_portal/setup.py | 6 ++++++ 5 files changed, 25 insertions(+), 16 deletions(-) create mode 120000 setup/fieldservice_portal/odoo/addons/fieldservice_portal create mode 100644 setup/fieldservice_portal/setup.py diff --git a/fieldservice_portal/README.rst b/fieldservice_portal/README.rst index 1ac4c41a8f..c91e2a3992 100644 --- a/fieldservice_portal/README.rst +++ b/fieldservice_portal/README.rst @@ -2,7 +2,7 @@ Field Service - Order Portal ============================ -.. +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! @@ -17,13 +17,13 @@ Field Service - Order Portal :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Ffield--service-lightgray.png?logo=github - :target: https://github.com/OCA/field-service/tree/14.0/fieldservice_portal + :target: https://github.com/OCA/field-service/tree/16.0/fieldservice_portal :alt: OCA/field-service .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/field-service-14-0/field-service-14-0-fieldservice_portal + :target: https://translation.odoo-community.org/projects/field-service-16-0/field-service-16-0-fieldservice_portal :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png - :target: https://runboat.odoo-community.org/builds?repo=OCA/field-service&target_branch=14.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/field-service&target_branch=16.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| @@ -42,7 +42,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -83,8 +83,8 @@ promote its widespread use. Current `maintainers `__: -|maintainer-aleuffre| |maintainer-renda-dev| +|maintainer-aleuffre| |maintainer-renda-dev| -This module is part of the `OCA/field-service `_ project on GitHub. +This module is part of the `OCA/field-service `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/fieldservice_portal/__manifest__.py b/fieldservice_portal/__manifest__.py index 07786fde2d..6a983e3a9c 100644 --- a/fieldservice_portal/__manifest__.py +++ b/fieldservice_portal/__manifest__.py @@ -1,6 +1,6 @@ { "name": "Field Service - Order Portal", - "version": "14.0.1.0.0", + "version": "16.0.1.0.0", "summary": """ Bridge module between fieldservice and portal. """, diff --git a/fieldservice_portal/static/description/index.html b/fieldservice_portal/static/description/index.html index 91c7e0be7f..50f093cf77 100644 --- a/fieldservice_portal/static/description/index.html +++ b/fieldservice_portal/static/description/index.html @@ -1,4 +1,3 @@ - @@ -9,10 +8,11 @@ /* :Author: David Goodger (goodger@python.org) -:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ +:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ :Copyright: This stylesheet has been placed in the public domain. Default cascading style sheet for the HTML output of Docutils. +Despite the name, some widely supported CSS2 features are used. See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to customize this style sheet. @@ -275,7 +275,7 @@ margin-left: 2em ; margin-right: 2em } -pre.code .ln { color: grey; } /* line numbers */ +pre.code .ln { color: gray; } /* line numbers */ pre.code, code { background-color: #eeeeee } pre.code .comment, code .comment { color: #5C6576 } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } @@ -301,7 +301,7 @@ span.pre { white-space: pre } -span.problematic { +span.problematic, pre.problematic { color: red } span.section-subtitle { @@ -369,7 +369,7 @@

Field Service - Order Portal

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:bfddb8307746f6f3179ded15fd2c7b9a6622c6e21d24ae73c9aece10a7f455f6 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/field-service Translate me on Weblate Try me on Runboat

+

Beta License: AGPL-3 OCA/field-service Translate me on Weblate Try me on Runboat

Bridge module between fieldservice and portal that allows portal users to monitor work orders related to their locations.

Table of contents

@@ -389,7 +389,7 @@

Bug Tracker

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -feedback.

+feedback.

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

@@ -415,13 +415,15 @@

Contributors

Maintainers

This module is maintained by the OCA.

-Odoo Community Association + +Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

Current maintainers:

aleuffre renda-dev

-

This module is part of the OCA/field-service project on GitHub.

+

This module is part of the OCA/field-service project on GitHub.

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

diff --git a/setup/fieldservice_portal/odoo/addons/fieldservice_portal b/setup/fieldservice_portal/odoo/addons/fieldservice_portal new file mode 120000 index 0000000000..02f7e77a7f --- /dev/null +++ b/setup/fieldservice_portal/odoo/addons/fieldservice_portal @@ -0,0 +1 @@ +../../../../fieldservice_portal \ No newline at end of file diff --git a/setup/fieldservice_portal/setup.py b/setup/fieldservice_portal/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/fieldservice_portal/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) From df8b7adbc24f05ca90d10dcff8452f2aa8c9307e Mon Sep 17 00:00:00 2001 From: anusrinps96 Date: Tue, 15 Oct 2024 17:15:40 +0200 Subject: [PATCH 3/3] [MIG] fieldservice_portal: Migation to 16.0 --- fieldservice_portal/README.rst | 6 +- fieldservice_portal/__manifest__.py | 7 +- .../controllers/fsm_order_portal.py | 27 +-- .../static/description/index.html | 6 +- .../static/src/js/fsm_order_portal.esm.js | 13 ++ fieldservice_portal/tests/__init__.py | 1 + fieldservice_portal/tests/test_portal.py | 171 ++++++++++++++++++ .../views/fsm_order_template.xml | 18 +- fieldservice_portal/views/portal_template.xml | 17 +- 9 files changed, 229 insertions(+), 37 deletions(-) create mode 100644 fieldservice_portal/static/src/js/fsm_order_portal.esm.js create mode 100644 fieldservice_portal/tests/__init__.py create mode 100644 fieldservice_portal/tests/test_portal.py diff --git a/fieldservice_portal/README.rst b/fieldservice_portal/README.rst index c91e2a3992..62b7b3f5f5 100644 --- a/fieldservice_portal/README.rst +++ b/fieldservice_portal/README.rst @@ -1,6 +1,6 @@ -============================ -Field Service - Order Portal -============================ +====================== +Field Service - Portal +====================== .. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/fieldservice_portal/__manifest__.py b/fieldservice_portal/__manifest__.py index 6a983e3a9c..b159c19e6a 100644 --- a/fieldservice_portal/__manifest__.py +++ b/fieldservice_portal/__manifest__.py @@ -1,5 +1,5 @@ { - "name": "Field Service - Order Portal", + "name": "Field Service - Portal", "version": "16.0.1.0.0", "summary": """ Bridge module between fieldservice and portal. @@ -23,6 +23,11 @@ "demo/fsm_location_demo.xml", "demo/fsm_order_demo.xml", ], + "assets": { + "web.assets_frontend": [ + "fieldservice_portal/static/src/js/fsm_order_portal.js", + ], + }, "installable": True, "application": False, } diff --git a/fieldservice_portal/controllers/fsm_order_portal.py b/fieldservice_portal/controllers/fsm_order_portal.py index 37ace8ab8d..8bf1be9b50 100644 --- a/fieldservice_portal/controllers/fsm_order_portal.py +++ b/fieldservice_portal/controllers/fsm_order_portal.py @@ -11,16 +11,17 @@ class CustomerPortal(CustomerPortal): - def _prepare_portal_layout_values(self): - values = super()._prepare_portal_layout_values() - fsm_order_count = ( - request.env["fsm.order"].search_count([]) - if request.env["fsm.order"].check_access_rights( - "read", raise_exception=False + def _prepare_home_portal_values(self, counters): + values = super()._prepare_home_portal_values(counters) + if "fsm_order_count" in counters: + fsm_order_count = ( + request.env["fsm.order"].search_count([]) + if request.env["fsm.order"].check_access_rights( + "read", raise_exception=False + ) + else 0 ) - else 0 - ) - values["fsm_order_count"] = fsm_order_count + values["fsm_order_count"] = fsm_order_count return values def _fsm_order_check_access(self, order_id): @@ -49,7 +50,7 @@ def fsm_order_get_page_view_values(self, order, **kwargs): return values @http.route( - ["/my/workorders", "/my/workorders/page/"], + ["/my/fsm_orders", "/my/fsm_orders/page/"], type="http", auth="user", website=True, @@ -154,7 +155,7 @@ def portal_my_fsm_orders( fsm_order_count = FsmOrder.search_count(domain) # pager pager = portal_pager( - url="/my/workorders", + url="/my/fsm_orders", url_args={}, total=fsm_order_count, page=page, @@ -182,7 +183,7 @@ def portal_my_fsm_orders( "grouped_orders": grouped_orders, "page_name": "fsm_order", "pager": pager, - "default_url": "/my/workorders", + "default_url": "/my/fsm_orders", "searchbar_sortings": searchbar_sortings, "searchbar_groupby": searchbar_groupby, "searchbar_inputs": searchbar_inputs, @@ -196,7 +197,7 @@ def portal_my_fsm_orders( return request.render("fieldservice_portal.portal_my_fsm_orders", values) @http.route( - ["/my/workorder/"], + ["/my/fsm_order/"], type="http", website=True, ) diff --git a/fieldservice_portal/static/description/index.html b/fieldservice_portal/static/description/index.html index 50f093cf77..509e880adb 100644 --- a/fieldservice_portal/static/description/index.html +++ b/fieldservice_portal/static/description/index.html @@ -3,7 +3,7 @@ -Field Service - Order Portal +Field Service - Portal -
-

Field Service - Order Portal

+
+

Field Service - Portal