Skip to content

Commit

Permalink
[MIG] fieldservice_stage_validation: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Juliette BLANC committed May 2, 2023
1 parent d5bb8d6 commit 2dcc004
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 36 deletions.
2 changes: 1 addition & 1 deletion fieldservice_stage_validation/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "FSM Stage Validation",
"summary": "Validate input data when reaching a Field Service stage",
"version": "15.0.1.0.0",
"version": "16.0.1.0.0",
"category": "Field Service",
"author": "Brian McMaster, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/field-service",
Expand Down
71 changes: 36 additions & 35 deletions fieldservice_stage_validation/tests/test_fsm_stage_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,131 +7,132 @@


class TestFSMStageValidation(TransactionCase):
def setUp(self):
super().setUp()
self.env = self.env(context=dict(self.env.context, tracking_disable=True))
self.stage = self.env["fsm.stage"]
self.fsm_order = self.env["fsm.order"]
self.fsm_person = self.env["fsm.person"]
self.fsm_location = self.env["fsm.location"]
self.fsm_equipment = self.env["fsm.equipment"]
self.ir_model_fields = self.env["ir.model.fields"]
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True))
cls.stage = cls.env["fsm.stage"]
cls.fsm_order = cls.env["fsm.order"]
cls.fsm_person = cls.env["fsm.person"]
cls.fsm_location = cls.env["fsm.location"]
cls.fsm_equipment = cls.env["fsm.equipment"]
cls.ir_model_fields = cls.env["ir.model.fields"]

# Get some fields to use in the stages
self.order_field = self.ir_model_fields.search(
cls.order_field = cls.ir_model_fields.search(
[("model", "=", "fsm.order"), ("name", "=", "description")]
)
self.person_field = self.ir_model_fields.search(
cls.person_field = cls.ir_model_fields.search(
[("model", "=", "fsm.person"), ("name", "=", "mobile")]
)
self.location_field = self.ir_model_fields.search(
cls.location_field = cls.ir_model_fields.search(
[("model", "=", "fsm.location"), ("name", "=", "direction")]
)
self.equipment_field = self.ir_model_fields.search(
cls.equipment_field = cls.ir_model_fields.search(
[("model", "=", "fsm.equipment"), ("name", "=", "notes")]
)

# For each model type, create a default stage and a stage
# which will apply field validation
# Order Stages
self.stage_order_default = self.stage.create(
cls.stage_order_default = cls.stage.create(
{
"name": "Order Stage Default",
"stage_type": "order",
"is_default": True,
"sequence": "10",
}
)
self.stage_order = self.stage.create(
cls.stage_order = cls.stage.create(
{
"name": "Order Stage Validate",
"stage_type": "order",
"validate_field_ids": [(6, 0, [self.order_field.id])],
"validate_field_ids": [(6, 0, [cls.order_field.id])],
"sequence": "11",
}
)
# Person Stages
self.stage_person_default = self.stage.create(
cls.stage_person_default = cls.stage.create(
{
"name": "Person Stage Default",
"stage_type": "worker",
"is_default": True,
"sequence": "10",
}
)
self.stage_person = self.stage.create(
cls.stage_person = cls.stage.create(
{
"name": "Person Stage Validate",
"stage_type": "worker",
"validate_field_ids": [(6, 0, [self.person_field.id])],
"validate_field_ids": [(6, 0, [cls.person_field.id])],
"sequence": "11",
}
)
# Location Stages
self.stage_location_default = self.stage.create(
cls.stage_location_default = cls.stage.create(
{
"name": "Location Stage Default",
"stage_type": "location",
"is_default": True,
"sequence": "10",
}
)
self.stage_location = self.stage.create(
cls.stage_location = cls.stage.create(
{
"name": "Location Stage Validate",
"stage_type": "location",
"validate_field_ids": [(6, 0, [self.location_field.id])],
"validate_field_ids": [(6, 0, [cls.location_field.id])],
"sequence": "11",
}
)
# Equipment Stages
self.stage_equipment_default = self.stage.create(
cls.stage_equipment_default = cls.stage.create(
{
"name": "Equipment Stage Default",
"stage_type": "equipment",
"is_default": True,
"sequence": "10",
}
)
self.stage_equipment = self.stage.create(
cls.stage_equipment = cls.stage.create(
{
"name": "Equipment Stage Validate",
"stage_type": "equipment",
"validate_field_ids": [(6, 0, [self.equipment_field.id])],
"validate_field_ids": [(6, 0, [cls.equipment_field.id])],
"sequence": "11",
}
)

# Create a person
self.person_01 = self.fsm_person.create(
cls.person_01 = cls.fsm_person.create(
{
"name": "FSM Worker 01",
"partner_id": self.env["res.partner"]
"partner_id": cls.env["res.partner"]
.create({"name": "Worker 01 Partner"})
.id,
"stage_id": self.stage_person_default.id,
"stage_id": cls.stage_person_default.id,
}
)
# Create a location
self.location_01 = self.fsm_location.create(
cls.location_01 = cls.fsm_location.create(
{
"name": "Location 01",
"owner_id": self.env["res.partner"]
"owner_id": cls.env["res.partner"]
.create({"name": "Location 01 Partner"})
.id,
"stage_id": self.stage_location_default.id,
"stage_id": cls.stage_location_default.id,
}
)
# Create an Equipment
self.equipment_01 = self.fsm_equipment.create(
cls.equipment_01 = cls.fsm_equipment.create(
{
"name": "Equipment 01",
"current_location_id": self.location_01.id,
"stage_id": self.stage_equipment_default.id,
"current_location_id": cls.location_01.id,
"stage_id": cls.stage_equipment_default.id,
}
)
# Create an Order
self.order_01 = self.fsm_order.create({"location_id": self.location_01.id})
cls.order_01 = cls.fsm_order.create({"location_id": cls.location_01.id})

def get_validate_message(self, stage):
stage_name = stage.name
Expand Down

0 comments on commit 2dcc004

Please sign in to comment.