Skip to content

Commit

Permalink
[IMP] fieldservice_portal: order visibility by stage
Browse files Browse the repository at this point in the history
  • Loading branch information
brian10048 committed Feb 5, 2025
1 parent 420ff02 commit 36710ec
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 2 deletions.
1 change: 1 addition & 0 deletions fieldservice_portal/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import models
from . import controllers
1 change: 1 addition & 0 deletions fieldservice_portal/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 7 additions & 2 deletions fieldservice_portal/controllers/fsm_order_portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand All @@ -24,6 +24,11 @@ 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])

Expand Down Expand Up @@ -69,7 +74,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"},
Expand Down
1 change: 1 addition & 0 deletions fieldservice_portal/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import fsm_stage
14 changes: 14 additions & 0 deletions fieldservice_portal/models/fsm_stage.py
Original file line number Diff line number Diff line change
@@ -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 of this stage in the portal",
)
9 changes: 9 additions & 0 deletions fieldservice_portal/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions fieldservice_portal/views/fsm_stage.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<odoo>
<record id="fsm_stage_form_view" model="ir.ui.view">
<field name="model">fsm.stage</field>
<field name="inherit_id" ref="fieldservice.fsm_stage_form_view" />
<field name="arch" type="xml">
<field name="is_default" position="after">
<field name="portal_visible" />
</field>
</field>
</record>
</odoo>

0 comments on commit 36710ec

Please sign in to comment.