diff --git a/fieldservice_account_analytic/models/fsm_location.py b/fieldservice_account_analytic/models/fsm_location.py
index 617bcc0dd4..a0affc0f4b 100644
--- a/fieldservice_account_analytic/models/fsm_location.py
+++ b/fieldservice_account_analytic/models/fsm_location.py
@@ -1,7 +1,7 @@
# Copyright (C) 2018 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-from odoo import api, fields, models
+from odoo import _, api, fields, models
class FSMLocation(models.Model):
@@ -70,3 +70,18 @@ def create(self, vals_list):
)
record.analytic_account_id = analytic_account
return record
+
+ def action_view_analytic_account(self):
+ self.ensure_one()
+ analytic_account = self.env["account.analytic.account"].search(
+ [("fsm_order_id", "=", self.id)], limit=1
+ )
+
+ if analytic_account:
+ return {
+ "type": "ir.actions.act_window",
+ "res_model": "account.analytic.account",
+ "view_mode": "form",
+ "res_id": analytic_account.id,
+ "name": _("Analytic Account for Location %s") % self.name,
+ }
diff --git a/fieldservice_account_analytic/models/fsm_order.py b/fieldservice_account_analytic/models/fsm_order.py
index d5664555b0..34bd6d8805 100644
--- a/fieldservice_account_analytic/models/fsm_order.py
+++ b/fieldservice_account_analytic/models/fsm_order.py
@@ -1,7 +1,7 @@
# Copyright (C) 2018 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-from odoo import api, fields, models
+from odoo import _, api, fields, models
class FSMOrder(models.Model):
@@ -56,3 +56,18 @@ def create(self, vals_list):
)
record.analytic_account_id = analytic_account
return record
+
+ def action_view_analytic_account(self):
+ self.ensure_one()
+ analytic_account = self.env["account.analytic.account"].search(
+ [("fsm_order_id", "=", self.id)], limit=1
+ )
+
+ if analytic_account:
+ return {
+ "type": "ir.actions.act_window",
+ "res_model": "account.analytic.account",
+ "view_mode": "form",
+ "res_id": analytic_account.id,
+ "name": _("Analytic Account for Order %s") % self.name,
+ }
diff --git a/fieldservice_account_analytic/views/fsm_location.xml b/fieldservice_account_analytic/views/fsm_location.xml
index d28616a45e..308c6634bd 100644
--- a/fieldservice_account_analytic/views/fsm_location.xml
+++ b/fieldservice_account_analytic/views/fsm_location.xml
@@ -16,6 +16,21 @@
fsm.location
+
+
+
diff --git a/fieldservice_account_analytic/views/fsm_order.xml b/fieldservice_account_analytic/views/fsm_order.xml
index 73b9480814..baad67f8cb 100644
--- a/fieldservice_account_analytic/views/fsm_order.xml
+++ b/fieldservice_account_analytic/views/fsm_order.xml
@@ -4,6 +4,21 @@
fsm.order
+
+
+