diff --git a/fieldservice/models/fsm_equipment.py b/fieldservice/models/fsm_equipment.py
index 824d2f4280..65d2c2a745 100644
--- a/fieldservice/models/fsm_equipment.py
+++ b/fieldservice/models/fsm_equipment.py
@@ -9,9 +9,14 @@ class FSMEquipment(models.Model):
_description = "Field Service Equipment"
_inherit = ["mail.thread", "mail.activity.mixin", "fsm.model.mixin"]
_stage_type = "equipment"
+ _check_company_auto = True
name = fields.Char(required=True)
- person_id = fields.Many2one("fsm.person", string="Assigned Operator")
+ person_id = fields.Many2one(
+ "fsm.person",
+ string="Assigned Operator",
+ check_company=True,
+ )
location_id = fields.Many2one("fsm.location", string="Assigned Location")
notes = fields.Text()
territory_id = fields.Many2one("res.territory", string="Territory")
@@ -19,10 +24,27 @@ class FSMEquipment(models.Model):
district_id = fields.Many2one("res.district", string="District")
region_id = fields.Many2one("res.region", string="Region")
current_location_id = fields.Many2one("fsm.location", string="Current Location")
- managed_by_id = fields.Many2one("res.partner", string="Managed By")
- owned_by_id = fields.Many2one("res.partner", string="Owned By")
- parent_id = fields.Many2one("fsm.equipment", string="Parent")
- child_ids = fields.One2many("fsm.equipment", "parent_id", string="Children")
+ managed_by_id = fields.Many2one(
+ "res.partner",
+ string="Managed By",
+ check_company=True,
+ )
+ owned_by_id = fields.Many2one(
+ "res.partner",
+ string="Owned By",
+ check_company=True,
+ )
+ parent_id = fields.Many2one(
+ "fsm.equipment",
+ string="Parent",
+ check_company=True,
+ )
+ child_ids = fields.One2many(
+ "fsm.equipment",
+ "parent_id",
+ string="Children",
+ check_company=True,
+ )
color = fields.Integer("Color Index")
company_id = fields.Many2one(
"res.company",
diff --git a/fieldservice/models/fsm_order.py b/fieldservice/models/fsm_order.py
index ca634655bd..f83d469f90 100644
--- a/fieldservice/models/fsm_order.py
+++ b/fieldservice/models/fsm_order.py
@@ -13,6 +13,7 @@ class FSMOrder(models.Model):
_name = "fsm.order"
_description = "Field Service Order"
_inherit = ["mail.thread", "mail.activity.mixin"]
+ _check_company_auto = True
def _default_stage_id(self):
stage = self.env["fsm.stage"].search(
@@ -71,6 +72,7 @@ def _track_subtype(self, init_values):
tracking=True,
index=True,
copy=False,
+ check_company=True,
group_expand="_read_group_stage_ids",
default=lambda self: self._default_stage_id(),
)
@@ -90,6 +92,7 @@ def _track_subtype(self, init_values):
"tag_id",
string="Tags",
help="Classify and analyze your orders",
+ check_company=True,
)
color = fields.Integer("Color Index", default=0)
team_id = fields.Many2one(
@@ -99,6 +102,7 @@ def _track_subtype(self, init_values):
index=True,
required=True,
tracking=True,
+ check_company=True,
)
# Request
@@ -153,7 +157,11 @@ def _calc_request_late(self, vals):
request_late = fields.Datetime(string="Latest Request Date")
description = fields.Text()
- person_ids = fields.Many2many("fsm.person", string="Field Service Workers")
+ person_ids = fields.Many2many(
+ "fsm.person",
+ string="Field Service Workers",
+ check_company=True,
+ )
@api.onchange("location_id")
def _onchange_location_id_customer(self):
diff --git a/fieldservice/models/fsm_stage.py b/fieldservice/models/fsm_stage.py
index 93790f2e2f..d412f7e226 100644
--- a/fieldservice/models/fsm_stage.py
+++ b/fieldservice/models/fsm_stage.py
@@ -11,6 +11,7 @@ class FSMStage(models.Model):
_name = "fsm.stage"
_description = "Field Service Stage"
_order = "sequence, name, id"
+ _check_company_auto = True
def _default_team_ids(self):
default_team_id = self.env.context.get("default_team_id")
@@ -63,6 +64,7 @@ def _default_team_ids(self):
"team_id",
string="Teams",
default=lambda self: self._default_team_ids(),
+ check_company=True,
)
def get_color_information(self):
diff --git a/fieldservice/models/fsm_tag.py b/fieldservice/models/fsm_tag.py
index d6c5b04291..2bf980aa20 100644
--- a/fieldservice/models/fsm_tag.py
+++ b/fieldservice/models/fsm_tag.py
@@ -7,9 +7,10 @@
class FSMTag(models.Model):
_name = "fsm.tag"
_description = "Field Service Tag"
+ _check_company_auto = True
name = fields.Char(required=True)
- parent_id = fields.Many2one("fsm.tag", string="Parent")
+ parent_id = fields.Many2one("fsm.tag", string="Parent", check_company=True)
color = fields.Integer("Color Index", default=10)
full_name = fields.Char(compute="_compute_full_name")
company_id = fields.Many2one(
diff --git a/fieldservice/models/fsm_team.py b/fieldservice/models/fsm_team.py
index b54f2cdfd7..d60520ffb8 100644
--- a/fieldservice/models/fsm_team.py
+++ b/fieldservice/models/fsm_team.py
@@ -8,6 +8,7 @@ class FSMTeam(models.Model):
_name = "fsm.team"
_description = "Field Service Team"
_inherit = ["mail.thread", "mail.activity.mixin"]
+ _check_company_auto = True
def _default_stages(self):
return self.env["fsm.stage"].search([("is_default", "=", True)])
@@ -60,12 +61,14 @@ def _compute_order_need_schedule_count(self):
"stage_id",
string="Stages",
default=_default_stages,
+ check_company=True,
)
order_ids = fields.One2many(
"fsm.order",
"team_id",
string="Orders",
domain=[("stage_id.is_closed", "=", False)],
+ check_company=True,
)
order_count = fields.Integer(compute="_compute_order_count", string="Orders Count")
order_need_assign_count = fields.Integer(
diff --git a/fieldservice/models/fsm_template.py b/fieldservice/models/fsm_template.py
index 8022f287be..b8fd3bd052 100644
--- a/fieldservice/models/fsm_template.py
+++ b/fieldservice/models/fsm_template.py
@@ -7,6 +7,7 @@
class FSMTemplate(models.Model):
_name = "fsm.template"
_description = "Field Service Order Template"
+ _check_company_auto = True
name = fields.Char(required=True)
instructions = fields.Text()
@@ -23,4 +24,5 @@ class FSMTemplate(models.Model):
"fsm.team",
string="Team",
help="Choose a team to be set on orders of this template",
+ check_company=True,
)
diff --git a/fieldservice/tests/test_fsm_order_template_onchange.py b/fieldservice/tests/test_fsm_order_template_onchange.py
index decb126473..a8ca6f2311 100644
--- a/fieldservice/tests/test_fsm_order_template_onchange.py
+++ b/fieldservice/tests/test_fsm_order_template_onchange.py
@@ -29,6 +29,7 @@ def test_fsm_order_onchange_template(self):
"category_ids": [(6, 0, categories)],
"duration": 2.25,
"type_id": self.fsm_type_a.id,
+ "company_id": self.env.company.id,
}
)
self.fsm_template_2 = self.env["fsm.template"].create(
@@ -38,6 +39,7 @@ def test_fsm_order_onchange_template(self):
"category_ids": [(6, 0, categories)],
"duration": 2.25,
"team_id": self.fsm_team_a.id,
+ "company_id": self.env.company.id,
}
)
self.fso = self.Order.create(
diff --git a/fieldservice/views/fsm_equipment.xml b/fieldservice/views/fsm_equipment.xml
index 15a486d7c8..62941046fe 100644
--- a/fieldservice/views/fsm_equipment.xml
+++ b/fieldservice/views/fsm_equipment.xml
@@ -61,6 +61,11 @@
+
@@ -113,6 +118,11 @@
options="{'no_create': True}"
groups="base.group_multi_company"
/>
+
diff --git a/fieldservice/views/fsm_order.xml b/fieldservice/views/fsm_order.xml
index 1ef6d6467d..b4bcf56ead 100644
--- a/fieldservice/views/fsm_order.xml
+++ b/fieldservice/views/fsm_order.xml
@@ -86,6 +86,11 @@
options="{'no_create': True}"
groups="base.group_multi_company"
/>
+
@@ -223,6 +228,11 @@
+
diff --git a/fieldservice/views/fsm_stage.xml b/fieldservice/views/fsm_stage.xml
index 479ddd9dd6..d0d2addae8 100644
--- a/fieldservice/views/fsm_stage.xml
+++ b/fieldservice/views/fsm_stage.xml
@@ -42,6 +42,11 @@
+
+
diff --git a/fieldservice/views/fsm_template.xml b/fieldservice/views/fsm_template.xml
index 7acc04548a..a74ddb3ce4 100644
--- a/fieldservice/views/fsm_template.xml
+++ b/fieldservice/views/fsm_template.xml
@@ -16,6 +16,11 @@
/>
+
@@ -37,6 +42,11 @@
options="{'no_create': True}"
groups="base.group_multi_company"
/>
+