Skip to content

Commit 1698629

Browse files
committed
Merge PR #1320 into 16.0
Signed-off-by brian10048
2 parents 9e1ea96 + dd86396 commit 1698629

File tree

9 files changed

+84
-13
lines changed

9 files changed

+84
-13
lines changed

fieldservice_portal/README.rst

+13
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,19 @@ to monitor work orders related to their locations.
3636
.. contents::
3737
:local:
3838

39+
Configuration
40+
=============
41+
42+
Set Portal Visibility for Order Stages
43+
44+
You are able to control which stages of field service orders are visible to
45+
portal users by enabling or disabling portal visiblity option on a stage.
46+
By default, all stages are visible in the portal. Disable the option to hide
47+
48+
#. Go to Field Service > Configuration > Stages
49+
#. Select an order stage.
50+
#. Toggle the Visible in Portal option as desired
51+
3952
Bug Tracker
4053
===========
4154

fieldservice_portal/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
from . import models
12
from . import controllers

fieldservice_portal/__manifest__.py

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"security/portal_security.xml",
1919
"views/fsm_order_template.xml",
2020
"views/portal_template.xml",
21+
"views/fsm_stage.xml",
2122
],
2223
"demo": [
2324
"demo/fsm_location_demo.xml",

fieldservice_portal/controllers/fsm_order_portal.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def _prepare_home_portal_values(self, counters):
1515
values = super()._prepare_home_portal_values(counters)
1616
if "fsm_order_count" in counters:
1717
fsm_order_count = (
18-
request.env["fsm.order"].search_count([])
18+
request.env["fsm.order"].search_count(self._prepare_fsm_orders_domain())
1919
if request.env["fsm.order"].check_access_rights(
2020
"read", raise_exception=False
2121
)
@@ -24,6 +24,9 @@ def _prepare_home_portal_values(self, counters):
2424
values["fsm_order_count"] = fsm_order_count
2525
return values
2626

27+
def _prepare_fsm_orders_domain(self):
28+
return [("stage_id.portal_visible", "=", True)]
29+
2730
def _fsm_order_check_access(self, order_id):
2831
fsm_order = request.env["fsm.order"].browse([order_id])
2932

@@ -69,7 +72,7 @@ def portal_my_fsm_orders(
6972
):
7073
values = self._prepare_portal_layout_values()
7174
FsmOrder = request.env["fsm.order"]
72-
domain = []
75+
domain = self._prepare_fsm_orders_domain()
7376

7477
searchbar_sortings = {
7578
"date": {"label": _("Newest"), "order": "request_early desc"},
@@ -130,7 +133,12 @@ def portal_my_fsm_orders(
130133
"domain": [("stage_id", "=", stage.id)],
131134
},
132135
)
133-
for stage in request.env["fsm.stage"].search([("stage_type", "=", "order")])
136+
for stage in request.env["fsm.stage"].search(
137+
[
138+
("stage_type", "=", "order"),
139+
("portal_visible", "=", True),
140+
]
141+
)
134142
)
135143
searchbar_filters.update(
136144
{
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import fsm_stage
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright (C) 2025, Brian McMaster
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
4+
from odoo import fields, models
5+
6+
7+
class FSMStage(models.Model):
8+
_inherit = "fsm.stage"
9+
10+
portal_visible = fields.Boolean(
11+
string="Visible in Portal",
12+
default=True,
13+
help="Enable to display field service orders based on it's stage in the portal",
14+
)
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Set Portal Visibility for Order Stages
2+
3+
You are able to control which stages of field service orders are visible to
4+
portal users by enabling or disabling portal visiblity option on a stage.
5+
By default, all stages are visible in the portal. Disable the option to hide
6+
7+
#. Go to Field Service > Configuration > Stages
8+
#. Select an order stage.
9+
#. Toggle the Visible in Portal option as desired

fieldservice_portal/static/description/index.html

+23-10
Original file line numberDiff line numberDiff line change
@@ -375,33 +375,46 @@ <h1 class="title">Field Service - Portal</h1>
375375
<p><strong>Table of contents</strong></p>
376376
<div class="contents local topic" id="contents">
377377
<ul class="simple">
378-
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-1">Bug Tracker</a></li>
379-
<li><a class="reference internal" href="#credits" id="toc-entry-2">Credits</a><ul>
380-
<li><a class="reference internal" href="#authors" id="toc-entry-3">Authors</a></li>
381-
<li><a class="reference internal" href="#contributors" id="toc-entry-4">Contributors</a></li>
382-
<li><a class="reference internal" href="#maintainers" id="toc-entry-5">Maintainers</a></li>
378+
<li><a class="reference internal" href="#configuration" id="toc-entry-1">Configuration</a></li>
379+
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-2">Bug Tracker</a></li>
380+
<li><a class="reference internal" href="#credits" id="toc-entry-3">Credits</a><ul>
381+
<li><a class="reference internal" href="#authors" id="toc-entry-4">Authors</a></li>
382+
<li><a class="reference internal" href="#contributors" id="toc-entry-5">Contributors</a></li>
383+
<li><a class="reference internal" href="#maintainers" id="toc-entry-6">Maintainers</a></li>
383384
</ul>
384385
</li>
385386
</ul>
386387
</div>
388+
<div class="section" id="configuration">
389+
<h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
390+
<p>Set Portal Visibility for Order Stages</p>
391+
<p>You are able to control which stages of field service orders are visible to
392+
portal users by enabling or disabling portal visiblity option on a stage.
393+
By default, all stages are visible in the portal. Disable the option to hide</p>
394+
<ol class="arabic simple">
395+
<li>Go to Field Service &gt; Configuration &gt; Stages</li>
396+
<li>Select an order stage.</li>
397+
<li>Toggle the Visible in Portal option as desired</li>
398+
</ol>
399+
</div>
387400
<div class="section" id="bug-tracker">
388-
<h1><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h1>
401+
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
389402
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/field-service/issues">GitHub Issues</a>.
390403
In case of trouble, please check there if your issue has already been reported.
391404
If you spotted it first, help us to smash it by providing a detailed and welcomed
392405
<a class="reference external" href="https://github.com/OCA/field-service/issues/new?body=module:%20fieldservice_portal%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
393406
<p>Do not contact contributors directly about support or help with technical issues.</p>
394407
</div>
395408
<div class="section" id="credits">
396-
<h1><a class="toc-backref" href="#toc-entry-2">Credits</a></h1>
409+
<h1><a class="toc-backref" href="#toc-entry-3">Credits</a></h1>
397410
<div class="section" id="authors">
398-
<h2><a class="toc-backref" href="#toc-entry-3">Authors</a></h2>
411+
<h2><a class="toc-backref" href="#toc-entry-4">Authors</a></h2>
399412
<ul class="simple">
400413
<li>PyTech SRL</li>
401414
</ul>
402415
</div>
403416
<div class="section" id="contributors">
404-
<h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
417+
<h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
405418
<ul>
406419
<li><p class="first"><a class="reference external" href="https://www.pytech.it">PyTech SRL</a>:</p>
407420
<blockquote>
@@ -413,7 +426,7 @@ <h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
413426
</ul>
414427
</div>
415428
<div class="section" id="maintainers">
416-
<h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
429+
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
417430
<p>This module is maintained by the OCA.</p>
418431
<a class="reference external image-reference" href="https://odoo-community.org">
419432
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<odoo>
2+
<record id="fsm_stage_form_view" model="ir.ui.view">
3+
<field name="model">fsm.stage</field>
4+
<field name="inherit_id" ref="fieldservice.fsm_stage_form_view" />
5+
<field name="arch" type="xml">
6+
<field name="is_default" position="after">
7+
<field name="portal_visible" />
8+
</field>
9+
</field>
10+
</record>
11+
</odoo>

0 commit comments

Comments
 (0)