Skip to content

Commit

Permalink
[ADD] fieldservice_mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
EdgarRetes committed Dec 2, 2024
1 parent 69e8c44 commit 83df1d1
Show file tree
Hide file tree
Showing 27 changed files with 986 additions and 0 deletions.
48 changes: 48 additions & 0 deletions fieldservice_mobile/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
.. image:: https://img.shields.io/badge/licence-LGPL--3-blue.svg
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3

====================
Field Service Mobile
====================

This module is manage FSM mobile stages based on configuration.

Configuration
=============

To configure this module, you need to:

* Go to Field Service > Configuration > Stages.
* Check Display in Mobile for display stage in FSM Mobile.
* Check Display in Odoo for display stage in Odoo FSM Order.
* Select a server action based on Stages.

* Manage domain on Automated Actions based on Stage sequence.

For Example:- If the Started stage sequence is 6.

* Go to Settings > Automated Actions > FSM Order Started Stage Update > Apply on > [["stage_id.sequence","=",6]]

Features on the mobile application will be visible depending on the groups set on this model.

Usage
=============
1) Navigate to the "Field Service" application
2) Under menu item "Configuration", select "FSM Mobile Features"
3) Select Installed Modules for FSM Mobile Dynamic Menu and it's records
4) Select a feature and add/remove groups

Credits
=======

* Open Source Integrators <https://opensourceintegrators.com>
* Serpent Consulting Services Pvt. Ltd. <[email protected]>

Contributors
~~~~~~~~~~~~

* Wolfgang Hall <[email protected]>
* Sandip Mangukiya <[email protected]>
* Serpent Consulting Services Pvt. Ltd. <[email protected]>
* Ammar Officewala <[email protected]>
3 changes: 3 additions & 0 deletions fieldservice_mobile/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models
38 changes: 38 additions & 0 deletions fieldservice_mobile/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright (C) 2020 Open Source Integrators
# Copyright (C) 2020 Serpent Consulting Services Pvt. Ltd.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Field Service - Mobile",
"summary": "Field Service Mobile Backend Support.",
"license": "AGPL-3",
"version": "18.0.1.0.0",
"category": "Field Service",
"author": "Open Source Integrators, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/field-service",
"depends": [
"fieldservice_stage_server_action",
"stock",
"analytic",
"maintenance",
"fieldservice_vehicle",
"fieldservice_sale",
"calendar",
],
"data": [
"security/ir_rule.xml",
"security/ir.model.access.csv",
"security/fieldservice_mobile_security.xml",
"data/server_actions.xml",
"data/base_automation.xml",
"data/feature_line.xml",
"data/feature_mapping.xml",
"views/res_config_settings.xml",
"views/fsm_stage_view.xml",
"views/fsm_order_view.xml",
"views/mobile_feature_mapping.xml",
"views/mobile_feature_line.xml",
],
"development_status": "Beta",
"maintainers": ["wolfhall"],
}
49 changes: 49 additions & 0 deletions fieldservice_mobile/data/base_automation.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<odoo>
<record id="fsm_order_started_stage_update" model="base.automation">
<field name="name">FSM Order Started Stage Update</field>
<field name="model_id" ref="fieldservice.model_fsm_order" />
<field name="trigger">on_write</field>
<field name="active" eval="True" />
<field name="filter_domain">[["stage_id.sequence", "=", 6]]</field>
<field
name="action_server_ids"
eval="[(4, ref('action_fsm_order_started_stage_update'))]"
/>
</record>

<record id="fsm_order_break_stage_update" model="base.automation">
<field name="name">FSM Order Break Stage Update</field>
<field name="model_id" ref="fieldservice.model_fsm_order" />
<field name="trigger">on_write</field>
<field name="active" eval="True" />
<field name="filter_domain">[["stage_id.sequence", "=", 7]]</field>
<field
name="action_server_ids"
eval="[(4, ref('action_fsm_order_break_stage_update'))]"
/>
</record>

<record id="fsm_order_resume_stage_update" model="base.automation">
<field name="name">FSM Order Resume Stage Update</field>
<field name="model_id" ref="fieldservice.model_fsm_order" />
<field name="trigger">on_write</field>
<field name="active" eval="True" />
<field name="filter_domain">[["stage_id.sequence", "=", 8]]</field>
<field
name="action_server_ids"
eval="[(4, ref('action_fsm_order_resume_stage_update'))]"
/>
</record>

<record id="fsm_order_completed_stage_update" model="base.automation">
<field name="name">FSM Order Completed Stage Update</field>
<field name="model_id" ref="fieldservice.model_fsm_order" />
<field name="trigger">on_write</field>
<field name="active" eval="True" />
<field name="filter_domain">[["stage_id.sequence", "=", 9]]</field>
<field
name="action_server_ids"
eval="[(4, ref('action_fsm_order_completed_stage_update'))]"
/>
</record>
</odoo>
107 changes: 107 additions & 0 deletions fieldservice_mobile/data/feature_line.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<odoo noupdate="1">
<!-- Feature Records -->
<record id="fsm_feature_location" model="fsm.mobile.feature.line">
<field name="name">Location</field>
<field name="code">LOC</field>
<field
name="group_ids"
eval='[(6, 0, [ref("fieldservice.group_fsm_manager")])]'
/>
</record>
<record id="fsm_feature_contact" model="fsm.mobile.feature.line">
<field name="name">Contact</field>
<field name="code">CON</field>
<field
name="group_ids"
eval='[(6, 0, [ref("fieldservice.group_fsm_manager")])]'
/>
</record>
<record id="fsm_feature_notes" model="fsm.mobile.feature.line">
<field name="name">Notes</field>
<field name="code">NOT</field>
<field
name="group_ids"
eval='[(6, 0, [ref("fieldservice.group_fsm_manager")])]'
/>
</record>
<record id="fsm_feature_chatter" model="fsm.mobile.feature.line">
<field name="name">Chatter</field>
<field name="code">CHA</field>
<field
name="group_ids"
eval='[(6, 0, [ref("fieldservice.group_fsm_manager")])]'
/>
</record>
<record id="fsm_feature_documents" model="fsm.mobile.feature.line">
<field name="name">Documents</field>
<field name="code">DOC</field>
<field
name="group_ids"
eval='[(6, 0, [ref("fieldservice.group_fsm_manager")])]'
/>
</record>
<record id="fsm_feature_picture" model="fsm.mobile.feature.line">
<field name="name">Pictures</field>
<field name="code">PIC</field>
<field
name="group_ids"
eval='[(6, 0, [ref("fieldservice.group_fsm_manager")])]'
/>
</record>
<record id="fsm_feature_timesheet" model="fsm.mobile.feature.line">
<field name="name">Timesheets</field>
<field name="code">TIM</field>
<field
name="group_ids"
eval='[(6, 0, [ref("fieldservice.group_fsm_manager")])]'
/>
</record>
<record id="fsm_feature_signature" model="fsm.mobile.feature.line">
<field name="name">Signature</field>
<field name="code">SIG</field>
<field
name="group_ids"
eval='[(6, 0, [ref("fieldservice.group_fsm_manager")])]'
/>
</record>
<record id="fsm_feature_equipment" model="fsm.mobile.feature.line">
<field name="name">Equipment</field>
<field name="code">EQU</field>
<field
name="group_ids"
eval='[(6, 0, [ref("fieldservice.group_fsm_manager")])]'
/>
</record>
<record id="fsm_feature_pickup_delivery" model="fsm.mobile.feature.line">
<field name="name">Pickup/Delivery</field>
<field name="code">DEL</field>
<field
name="group_ids"
eval='[(6, 0, [ref("fieldservice.group_fsm_manager")])]'
/>
</record>
<record id="fsm_feature_sale_order_line" model="fsm.mobile.feature.line">
<field name="name">Sale Order Lines</field>
<field name="code">SOL</field>
<field
name="group_ids"
eval='[(6, 0, [ref("fieldservice.group_fsm_manager")])]'
/>
</record>
<record id="fsm_feature_durations" model="fsm.mobile.feature.line">
<field name="name">Durations</field>
<field name="code">DUR</field>
<field
name="group_ids"
eval='[(6, 0, [ref("fieldservice.group_fsm_manager")])]'
/>
</record>
<record id="fsm_feature_stock_request" model="fsm.mobile.feature.line">
<field name="name">Stock Requests</field>
<field name="code">STO</field>
<field
name="group_ids"
eval='[(6, 0, [ref("fieldservice.group_fsm_manager")])]'
/>
</record>
</odoo>
28 changes: 28 additions & 0 deletions fieldservice_mobile/data/feature_mapping.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<odoo noupdate="1">
<!-- FSM Mobile Feature Mapping Record -->
<record id="fsm_feature_default_mapping" model="fsm.mobile.feature.mapping">
<field name="name">Default FSM Mobile Feature Mapping</field>
<field
name="installed_module_ids"
eval='[(6, 0, [ref("base.module_fieldservice"),
ref("base.module_fieldservice_stage_server_action"),
ref("base.module_fieldservice_mobile")])]'
/>
<field
name="feature_line_ids"
eval='[(6, 0, [ref("fieldservice_mobile.fsm_feature_location"),
ref("fieldservice_mobile.fsm_feature_contact"),
ref("fieldservice_mobile.fsm_feature_notes"),
ref("fieldservice_mobile.fsm_feature_chatter"),
ref("fieldservice_mobile.fsm_feature_documents"),
ref("fieldservice_mobile.fsm_feature_picture"),
ref("fieldservice_mobile.fsm_feature_timesheet"),
ref("fieldservice_mobile.fsm_feature_signature"),
ref("fieldservice_mobile.fsm_feature_equipment"),
ref("fieldservice_mobile.fsm_feature_pickup_delivery"),
ref("fieldservice_mobile.fsm_feature_sale_order_line"),
ref("fieldservice_mobile.fsm_feature_durations"),
ref("fieldservice_mobile.fsm_feature_stock_request")])]'
/>
</record>
</odoo>
103 changes: 103 additions & 0 deletions fieldservice_mobile/data/server_actions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<odoo>
<record id="action_fsm_order_started_stage_update" model="ir.actions.server">
<field name="name">FSM Order Started Stage Update Action</field>
<field name="model_id" ref="fieldservice.model_fsm_order" />
<field name="state">code</field>
<field name="code">
for rec in records:
stage_rec = env['fsm.stage.history'].search([('order_id', '=', rec.id)], order='id desc', limit=1)
call_it = False
if not stage_rec:
call_it = True
if stage_rec.stage_id != rec.stage_id:
call_it = True
if call_it and rec.stage_id.action_id:
rec.write({
'date_start': datetime.datetime.now(),
'fsm_stage_history_ids': [(0, 0, {
'start_datetime': datetime.datetime.now(),
'stage_id': rec.stage_id.id,
'duration': 0.0,
'total_duration': 0.0,
})]
})
</field>
</record>

<record id="action_fsm_order_break_stage_update" model="ir.actions.server">
<field name="name">FSM Order Break Stage Update Action</field>
<field name="model_id" ref="fieldservice.model_fsm_order" />
<field name="state">code</field>
<field name="code">
for rec in records:
stage_rec = env['fsm.stage.history'].search([('order_id', '=', rec.id)], order='id desc', limit=1)
call_it = False
if not stage_rec:
call_it = True
if stage_rec.stage_id != rec.stage_id:
call_it = True
if call_it and rec.stage_id.action_id:
delta = datetime.datetime.now() - stage_rec.start_datetime
duration = round((delta.total_seconds() / 3600), 2)
rec.write({
'fsm_stage_history_ids': [(0, 0, {
'start_datetime': datetime.datetime.now(),
'stage_id': rec.stage_id.id,
'duration': duration,
'total_duration': round((duration + stage_rec.total_duration), 2),
})]
})
</field>
</record>

<record id="action_fsm_order_resume_stage_update" model="ir.actions.server">
<field name="name">FSM Order Resume Stage Update Action</field>
<field name="model_id" ref="fieldservice.model_fsm_order" />
<field name="state">code</field>
<field name="code">
for rec in records:
stage_rec = env['fsm.stage.history'].search([('order_id', '=', rec.id)], order='id desc', limit=1)
call_it = False
if not stage_rec:
call_it = True
if stage_rec.stage_id != rec.stage_id:
call_it = True
if call_it and rec.stage_id.action_id:
rec.write({
'fsm_stage_history_ids': [(0, 0, {
'start_datetime': datetime.datetime.now(),
'stage_id': rec.stage_id.id,
'duration': 0.0,
'total_duration': round((rec.duration + stage_rec.total_duration), 2),
})]
})
</field>
</record>

<record id="action_fsm_order_completed_stage_update" model="ir.actions.server">
<field name="name">FSM Order Completed Stage Update Action</field>
<field name="model_id" ref="fieldservice.model_fsm_order" />
<field name="state">code</field>
<field name="code">
for rec in records:
stage_rec = env['fsm.stage.history'].search([('order_id', '=', rec.id)], order='id desc', limit=1)
call_it = False
if not stage_rec:
call_it = True
if stage_rec.stage_id != rec.stage_id:
call_it = True
if call_it and rec.stage_id.action_id:
delta = datetime.datetime.now() - stage_rec.start_datetime
duration = round((delta.total_seconds() / 3600), 2)
rec.write({
'date_end': datetime.datetime.now(),
'fsm_stage_history_ids': [(0, 0, {
'start_datetime': datetime.datetime.now(),
'stage_id': rec.stage_id.id,
'duration': duration,
'total_duration': round((duration + stage_rec.total_duration), 2),
})]
})
</field>
</record>
</odoo>
10 changes: 10 additions & 0 deletions fieldservice_mobile/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import fsm_stage
from . import fsm_order
from . import fsm_stage_history
from . import res_config_settings
from . import res_users
from . import ir_attachment
from . import fsm_mobile_feature_mapping
from . import fsm_mobile_feature_line
Loading

0 comments on commit 83df1d1

Please sign in to comment.