diff --git a/fieldservice_portal/README.rst b/fieldservice_portal/README.rst index 9087414188..6ee980b104 100644 --- a/fieldservice_portal/README.rst +++ b/fieldservice_portal/README.rst @@ -36,6 +36,19 @@ to monitor work orders related to their locations. .. contents:: :local: +Configuration +============= + +Set Portal Visibility for Order Stages + +You are able to control which stages of field service orders are visible to +portal users by enabling or disabling portal visiblity option on a stage. +By default, all stages are visible in the portal. Disable the option to hide + +#. Go to Field Service > Configuration > Stages +#. Select an order stage. +#. Toggle the Visible in Portal option as desired + Bug Tracker =========== diff --git a/fieldservice_portal/__init__.py b/fieldservice_portal/__init__.py index e046e49fbe..f7209b1710 100644 --- a/fieldservice_portal/__init__.py +++ b/fieldservice_portal/__init__.py @@ -1 +1,2 @@ +from . import models from . import controllers diff --git a/fieldservice_portal/__manifest__.py b/fieldservice_portal/__manifest__.py index bd32d25cf3..a48c668ae9 100644 --- a/fieldservice_portal/__manifest__.py +++ b/fieldservice_portal/__manifest__.py @@ -18,6 +18,7 @@ "security/portal_security.xml", "views/fsm_order_template.xml", "views/portal_template.xml", + "views/fsm_stage.xml", ], "demo": [ "demo/fsm_location_demo.xml", diff --git a/fieldservice_portal/controllers/fsm_order_portal.py b/fieldservice_portal/controllers/fsm_order_portal.py index 8bc1bb2eb2..f55a10d711 100644 --- a/fieldservice_portal/controllers/fsm_order_portal.py +++ b/fieldservice_portal/controllers/fsm_order_portal.py @@ -15,7 +15,7 @@ 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([]) + request.env["fsm.order"].search_count(self._prepare_fsm_orders_domain()) if request.env["fsm.order"].check_access_rights( "read", raise_exception=False ) @@ -24,6 +24,9 @@ def _prepare_home_portal_values(self, counters): values["fsm_order_count"] = fsm_order_count return values + def _prepare_fsm_orders_domain(self): + return [("stage_id.portal_visible", "=", True)] + def _fsm_order_check_access(self, order_id): fsm_order = request.env["fsm.order"].browse([order_id]) @@ -69,7 +72,7 @@ def portal_my_fsm_orders( ): values = self._prepare_portal_layout_values() FsmOrder = request.env["fsm.order"] - domain = [] + domain = self._prepare_fsm_orders_domain() searchbar_sortings = { "date": {"label": _("Newest"), "order": "request_early desc"}, @@ -129,7 +132,12 @@ def portal_my_fsm_orders( "domain": [("stage_id", "=", stage.id)], }, ) - for stage in request.env["fsm.stage"].search([("stage_type", "=", "order")]) + for stage in request.env["fsm.stage"].search( + [ + ("stage_type", "=", "order"), + ("portal_visible", "=", True), + ] + ) ) searchbar_filters.update( { diff --git a/fieldservice_portal/models/__init__.py b/fieldservice_portal/models/__init__.py new file mode 100644 index 0000000000..e468c33233 --- /dev/null +++ b/fieldservice_portal/models/__init__.py @@ -0,0 +1 @@ +from . import fsm_stage diff --git a/fieldservice_portal/models/fsm_stage.py b/fieldservice_portal/models/fsm_stage.py new file mode 100644 index 0000000000..9ddf760330 --- /dev/null +++ b/fieldservice_portal/models/fsm_stage.py @@ -0,0 +1,14 @@ +# Copyright (C) 2025, Brian McMaster +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class FSMStage(models.Model): + _inherit = "fsm.stage" + + portal_visible = fields.Boolean( + string="Visible in Portal", + default=True, + help="Enable to display field service orders based on it's stage in the portal", + ) diff --git a/fieldservice_portal/readme/CONFIGURE.rst b/fieldservice_portal/readme/CONFIGURE.rst new file mode 100644 index 0000000000..66b5fc200a --- /dev/null +++ b/fieldservice_portal/readme/CONFIGURE.rst @@ -0,0 +1,9 @@ +Set Portal Visibility for Order Stages + +You are able to control which stages of field service orders are visible to +portal users by enabling or disabling portal visiblity option on a stage. +By default, all stages are visible in the portal. Disable the option to hide + +#. Go to Field Service > Configuration > Stages +#. Select an order stage. +#. Toggle the Visible in Portal option as desired diff --git a/fieldservice_portal/static/description/index.html b/fieldservice_portal/static/description/index.html index 21a6ef0d13..3685669b13 100644 --- a/fieldservice_portal/static/description/index.html +++ b/fieldservice_portal/static/description/index.html @@ -375,17 +375,30 @@

Field Service - Portal

Table of contents

+
+

Configuration

+

Set Portal Visibility for Order Stages

+

You are able to control which stages of field service orders are visible to +portal users by enabling or disabling portal visiblity option on a stage. +By default, all stages are visible in the portal. Disable the option to hide

+
    +
  1. Go to Field Service > Configuration > Stages
  2. +
  3. Select an order stage.
  4. +
  5. Toggle the Visible in Portal option as desired
  6. +
+
-

Bug Tracker

+

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 @@ -393,15 +406,15 @@

Bug Tracker

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

-

Credits

+

Credits

-

Authors

+

Authors

-

Contributors

+

Contributors

-

Maintainers

+

Maintainers

This module is maintained by the OCA.

Odoo Community Association diff --git a/fieldservice_portal/views/fsm_stage.xml b/fieldservice_portal/views/fsm_stage.xml new file mode 100644 index 0000000000..11398a76bd --- /dev/null +++ b/fieldservice_portal/views/fsm_stage.xml @@ -0,0 +1,11 @@ + + + fsm.stage + + + + + + + +