Skip to content

Commit

Permalink
Merge PR #1321 into 17.0
Browse files Browse the repository at this point in the history
Signed-off-by brian10048
  • Loading branch information
OCA-git-bot committed Feb 10, 2025
2 parents 852c9c8 + 81b0fc3 commit fa88fa3
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 17 deletions.
22 changes: 18 additions & 4 deletions fieldservice_portal/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,20 @@ 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

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

Bug Tracker
===========

Expand All @@ -57,13 +71,13 @@ Authors
Contributors
------------

- `PyTech SRL <https://www.pytech.it>`__:
- `PyTech SRL <https://www.pytech.it>`__:

- Alessio Renda <alessio.renda@pytech.it>
- Alessio Renda <alessio.renda@pytech.it>

- `APSL-Nagarro <https://apsl.tech>`__:
- `APSL-Nagarro <https://apsl.tech>`__:

- Antoni Marroig <amarroig@apsl.net>
- Antoni Marroig <amarroig@apsl.net>

Maintainers
-----------
Expand Down
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
14 changes: 11 additions & 3 deletions fieldservice_portal/controllers/fsm_order_portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,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 @@ -25,6 +25,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])

Expand Down Expand Up @@ -70,7 +73,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 Expand Up @@ -131,7 +134,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(
{
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 based on it's stage in the portal",
)
10 changes: 10 additions & 0 deletions fieldservice_portal/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
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. Select an order stage.
3. Toggle the Visible in Portal option as desired
34 changes: 24 additions & 10 deletions fieldservice_portal/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -375,33 +375,47 @@ <h1 class="title">Field Service - Portal</h1>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-1">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-2">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-3">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-4">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-5">Maintainers</a></li>
<li><a class="reference internal" href="#configuration" id="toc-entry-1">Configuration</a></li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-2">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-3">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-4">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-5">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-6">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="configuration">
<h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
<p>Set Portal Visibility for Order Stages</p>
<p>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</p>
<ol class="arabic simple">
<li>Go to Field Service &gt; Configuration &gt; Stages</li>
<li>Select an order stage.</li>
<li>Toggle the Visible in Portal option as desired</li>
</ol>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h1>
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/field-service/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/field-service/issues/new?body=module:%20fieldservice_portal%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#toc-entry-2">Credits</a></h1>
<h1><a class="toc-backref" href="#toc-entry-3">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#toc-entry-3">Authors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-4">Authors</a></h2>
<ul class="simple">
<li>PyTech SRL</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<ul>
<li><p class="first"><a class="reference external" href="https://www.pytech.it">PyTech SRL</a>:</p>
<blockquote>
Expand All @@ -420,7 +434,7 @@ <h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
Expand Down
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 fa88fa3

Please sign in to comment.