Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 111 additions & 0 deletions fieldservice_survey/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
===================
Fieldservice Survey
===================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:f30f866be07068c593eb0ccaa0c5a07a84560d05d580608d4a172e14d178650b
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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/18.0/fieldservice_survey
: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-18-0/field-service-18-0-fieldservice_survey
: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=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module introduces enhanced survey functionalities in the Field
Service module, streamlining the process of collecting and analyzing
feedback for service orders. Users can seamlessly navigate to Field
Service, access settings, and select a customized FSM Order Survey
Template. When generating a new order, the system prompts users to
submit a survey, facilitating efficient data collection.

The module further extends capabilities by incorporating an intuitive
"Survey Answer" button within the order interface. This button provides
users with the flexibility to either view comprehensive statistics
derived from survey responses or directly edit the survey for any
necessary adjustments.

With the Field Service Survey Enhancements module, businesses can
effortlessly manage and optimize their survey processes, gaining
valuable insights into service performance and customer satisfaction.

**Table of contents**

.. contents::
:local:

Usage
=====

- Navigate to Field Service
- Go to Settings
- Choose a FSM Order Survey Template
- Generate a new order
- Submit Survey
- Access the "Survey Answer" button in the order to either view the
statistics or edit the survey.

Known issues / Roadmap
======================

- Improve survey data integrity by updating the fsm_order_person_id
field in response to changes in the field service order's person_id.

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/field-service/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 <https://github.com/OCA/field-service/issues/new?body=module:%20fieldservice_survey%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
-------

* Escodoo

Contributors
------------

- `Escodoo <https://www.escodoo.com.br>`__:

- Marcel Savegnago <[email protected]>
- Kaynnan Lemes <[email protected]>

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.

This module is part of the `OCA/field-service <https://github.com/OCA/field-service/tree/18.0/fieldservice_survey>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions fieldservice_survey/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import models
from . import wizard
from . import controllers
28 changes: 28 additions & 0 deletions fieldservice_survey/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2023 - TODAY, Escodoo
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Fieldservice Survey",
"summary": """
This module enable integration the fieldservice app with survey""",
"version": "18.0.1.0.0",
"license": "AGPL-3",
"author": "Escodoo,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/field-service",
"depends": [
"fieldservice",
"survey",
],
"data": [
"security/res_groups.xml",
"security/ir.model.access.csv",
"views/res_config_settings.xml",
"views/survey_survey.xml",
"views/survey_user_input.xml",
"views/fsm_order.xml",
"views/survey_templates_statistics.xml",
"data/fsm_order_survey_data.xml",
"data/mail_data.xml",
"wizard/fsm_order_survey_submit.xml",
],
}
1 change: 1 addition & 0 deletions fieldservice_survey/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import main
130 changes: 130 additions & 0 deletions fieldservice_survey/controllers/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# Copyright 2023 - TODAY, Marcel Savegnago <[email protected]>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import http
from odoo.exceptions import AccessDenied
from odoo.http import request
from odoo.osv import expression

from odoo.addons.survey.controllers.main import Survey

FSM_ORDER_ID = "fsm_order_id"
PARTNER_ID = "partner_id"
FSM_ORDER_PERSON_ID = "fsm_order_person_id"


class FsmOrderSurveySurvey(Survey):
def _get_user_input_domain(self, survey, line_filter_domain, **post):
user_input_domain = super()._get_user_input_domain(
survey, line_filter_domain, **post
)

fsm_order_id = post.get(FSM_ORDER_ID)
if not fsm_order_id:
return user_input_domain

try:
fsm_order = request.env["fsm.order"].sudo().browse(int(fsm_order_id))
except ValueError:
raise AccessDenied(request.env._("Invalid FSM Order ID")) from None

user = request.env.user
partner = user.partner_id
person = request.env["fsm.person"].search([(PARTNER_ID, "=", partner.id)])

if user.has_group("fieldservice_survey.group_fsm_survey_user"):
return expression.AND(
[[("fsm_order_id", "=", fsm_order.id)], user_input_domain]
)

if partner.id in fsm_order.partner_submitted_answer_survey_ids.ids:
return expression.AND(
[
[FSM_ORDER_ID, "=", fsm_order.id],
[FSM_ORDER_PERSON_ID, "=", person.id],
],
user_input_domain,
)

raise AccessDenied(
request.env._("You do not have access to this FSM Order Survey")
)

@http.route(
"/fsm_order/<int:fsm_order_id>/results", type="http", auth="user", website=True
)
def survey_results(self, fsm_order_id, **post):
try:
fsm_order = request.env["fsm.order"].sudo().browse(fsm_order_id)
except ValueError:
raise AccessDenied(request.env._("Invalid FSM Order ID")) from None

if (
fsm_order.person_id.partner_id == request.env.user.partner_id
and not request.env.user.has_group(
"fieldservice_survey.group_fsm_survey_user"
)
):
return request.render(
"http_routing.http_error",
{
"status_code": "Forbidden",
"status_message": "You don't have access to this survey "
"related to your FSM Order.",
},
)

user = request.env.user
partner = user.partner_id
person = request.env["fsm.person"].search([(PARTNER_ID, "=", partner.id)])
survey_sudo = None
answer = None

if user.has_group(
"fieldservice_survey.group_fsm_survey_user"
) or user.has_group("base.group_system"):
survey_sudo = (
request.env["survey.user_input"]
.sudo()
.search([(FSM_ORDER_ID, "=", fsm_order.id)], limit=1)
.survey_id
)

if partner.id in fsm_order.partner_submitted_answer_survey_ids.ids:
answer = (
request.env["survey.user_input"]
.sudo()
.search(
[
(FSM_ORDER_ID, "=", fsm_order.id),
(FSM_ORDER_PERSON_ID, "=", person.id),
],
limit=1,
)
)

if answer:
survey_sudo = answer.survey_id

if not survey_sudo:
raise AccessDenied(request.env._("No survey found for the given FSM Order"))

post["fsm_order_id"] = fsm_order_id
user_input_lines_sudo, search_filters = self._extract_filters_data(
survey_sudo, post
)
survey_data = survey_sudo._prepare_statistics(user_input_lines_sudo)
question_and_page_data = survey_sudo.question_and_page_ids._prepare_statistics(
user_input_lines_sudo
)

template_values = {
"survey": survey_sudo,
"question_and_page_data": question_and_page_data,
"survey_data": survey_data,
"search_filters": search_filters,
"search_finished": "true",
"fsm_order_id": fsm_order_id,
}

return request.render("survey.survey_page_statistics", template_values)
Loading
Loading