[IMP]pms: class_id room_type required

This commit is contained in:
Darío Lodeiros
2021-01-31 13:31:01 +01:00
parent e6c67783ff
commit 1b4cc559a9
2 changed files with 34 additions and 2 deletions

View File

@@ -27,7 +27,11 @@ class PmsRoomType(models.Model):
ondelete="cascade",
)
room_ids = fields.One2many("pms.room", "room_type_id", "Rooms")
class_id = fields.Many2one("pms.room.type.class", "Property Type Class")
class_id = fields.Many2one(
"pms.room.type.class",
"Property Type Class",
required=True,
)
board_service_room_type_ids = fields.One2many(
"pms.board.service.room.type", "pms_room_type_id", string="Board Services"
)
@@ -117,7 +121,7 @@ class PmsRoomType(models.Model):
@api.constrains("pms_property_ids")
def _check_integrity_property_class(self):
for record in self:
if record.pms_property_ids and record.class_id:
if record.pms_property_ids and record.class_id.pms_property_ids:
for pms_property in record.pms_property_ids:
if pms_property.id not in record.class_id.pms_property_ids.ids:
raise ValidationError(

View File

@@ -52,6 +52,7 @@ class TestRoomTypeCodePropertyIntegrity(TestRoomType):
"code_type": "c1",
"pms_property_ids": [(6, 0, [self.p1.id])],
"company_id": self.m1.id,
"class_id": self.ref("pms.pms_room_type_class_0"),
}
)
except ValidationError:
@@ -79,6 +80,7 @@ class TestRoomTypeCodePropertyIntegrity(TestRoomType):
"code_type": "c1",
"pms_property_ids": [(6, 0, [self.p1.id])],
"company_id": self.m2.id,
"class_id": self.ref("pms.pms_room_type_class_0"),
}
)
@@ -105,6 +107,7 @@ class TestRoomTypeCodePropertyIntegrity(TestRoomType):
"code_type": "c1",
"pms_property_ids": [(6, 0, [self.p1.id, self.p3.id])],
"company_id": self.m2.id,
"class_id": self.ref("pms.pms_room_type_class_0"),
}
)
@@ -128,6 +131,7 @@ class TestRoomTypeCodePropertyIntegrity(TestRoomType):
"code_type": "c1",
"pms_property_ids": [(6, 0, [self.p1.id, self.p3.id])],
"company_id": False,
"class_id": self.ref("pms.pms_room_type_class_0"),
}
)
except ValidationError:
@@ -157,6 +161,7 @@ class TestRoomTypeCodePropertyIntegrity(TestRoomType):
"code_type": "c1",
"pms_property_ids": [(6, 0, [self.p1.id])],
"company_id": False,
"class_id": self.ref("pms.pms_room_type_class_0"),
}
)
@@ -171,6 +176,7 @@ class TestRoomTypeCodePropertyIntegrity(TestRoomType):
"code_type": "c1",
"pms_property_ids": [(6, 0, [self.p1.id])],
"company_id": False,
"class_id": self.ref("pms.pms_room_type_class_0"),
}
)
@@ -197,6 +203,7 @@ class TestRoomTypeCodePropertyIntegrity(TestRoomType):
"code_type": "c1",
"pms_property_ids": [(6, 0, [self.p1.id])],
"company_id": False,
"class_id": self.ref("pms.pms_room_type_class_0"),
}
)
@@ -211,6 +218,7 @@ class TestRoomTypeCodePropertyIntegrity(TestRoomType):
"code_type": "c1",
"pms_property_ids": [(6, 0, [self.p1.id])],
"company_id": self.m1.id,
"class_id": self.ref("pms.pms_room_type_class_0"),
}
)
@@ -238,6 +246,7 @@ class TestRoomTypeCodePropertyIntegrity(TestRoomType):
"code_type": "c1",
"pms_property_ids": [(6, 0, [self.p1.id])],
"company_id": self.m1.id,
"class_id": self.ref("pms.pms_room_type_class_0"),
}
)
@@ -252,6 +261,7 @@ class TestRoomTypeCodePropertyIntegrity(TestRoomType):
"code_type": "c1",
"pms_property_ids": [(6, 0, [self.p1.id, self.p2.id, self.p3.id])],
"company_id": False,
"class_id": self.ref("pms.pms_room_type_class_0"),
}
)
@@ -276,6 +286,7 @@ class TestRoomTypeCodePropertyUniqueness(TestRoomType):
"code_type": "c1",
"pms_property_ids": [(6, 0, [self.p1.id, self.p3.id])],
"company_id": False,
"class_id": self.ref("pms.pms_room_type_class_0"),
}
)
@@ -306,6 +317,7 @@ class TestRoomTypeCodePropertyUniqueness(TestRoomType):
"code_type": "c1",
"pms_property_ids": [(6, 0, [self.p1.id, self.p3.id])],
"company_id": False,
"class_id": self.ref("pms.pms_room_type_class_0"),
}
)
@@ -336,6 +348,7 @@ class TestRoomTypeCodePropertyUniqueness(TestRoomType):
"code_type": "c1",
"pms_property_ids": [(6, 0, [self.p1.id, self.p2.id])],
"company_id": False,
"class_id": self.ref("pms.pms_room_type_class_0"),
}
)
@@ -364,6 +377,7 @@ class TestRoomTypeCodePropertyUniqueness(TestRoomType):
"code_type": "c1",
"pms_property_ids": False,
"company_id": self.m1.id,
"class_id": self.ref("pms.pms_room_type_class_0"),
}
)
@@ -393,6 +407,7 @@ class TestRoomTypeCodePropertyUniqueness(TestRoomType):
"code_type": "c1",
"pms_property_ids": False,
"company_id": self.m1.id,
"class_id": self.ref("pms.pms_room_type_class_0"),
}
)
@@ -427,6 +442,7 @@ class TestRoomTypeCodePropertyUniqueness(TestRoomType):
"code_type": "c1",
"pms_property_ids": [(6, 0, [self.p1.id, self.p3.id])],
"company_id": False,
"class_id": self.ref("pms.pms_room_type_class_0"),
}
)
# r2
@@ -436,6 +452,7 @@ class TestRoomTypeCodePropertyUniqueness(TestRoomType):
"code_type": "c1",
"pms_property_ids": False,
"company_id": False,
"class_id": self.ref("pms.pms_room_type_class_0"),
}
)
@@ -470,6 +487,7 @@ class TestRoomTypeCodePropertyUniqueness(TestRoomType):
"code_type": "c1",
"pms_property_ids": [(6, 0, [self.p1.id])],
"company_id": False,
"class_id": self.ref("pms.pms_room_type_class_0"),
}
)
r2 = self.env["pms.room.type"].create(
@@ -478,6 +496,7 @@ class TestRoomTypeCodePropertyUniqueness(TestRoomType):
"code_type": "c1",
"pms_property_ids": False,
"company_id": False,
"class_id": self.ref("pms.pms_room_type_class_0"),
}
)
@@ -512,6 +531,7 @@ class TestRoomTypeCodePropertyUniqueness(TestRoomType):
"code_type": "c1",
"pms_property_ids": [(6, 0, [self.p1.id])],
"company_id": False,
"class_id": self.ref("pms.pms_room_type_class_0"),
}
)
r2 = self.env["pms.room.type"].create(
@@ -520,6 +540,7 @@ class TestRoomTypeCodePropertyUniqueness(TestRoomType):
"code_type": "c1",
"pms_property_ids": False,
"company_id": False,
"class_id": self.ref("pms.pms_room_type_class_0"),
}
)
@@ -554,6 +575,7 @@ class TestRoomTypeCodePropertyUniqueness(TestRoomType):
"code_type": "c1",
"pms_property_ids": [(6, 0, [self.p1.id])],
"company_id": False,
"class_id": self.ref("pms.pms_room_type_class_0"),
}
)
# r2
@@ -563,6 +585,7 @@ class TestRoomTypeCodePropertyUniqueness(TestRoomType):
"code_type": "c1",
"pms_property_ids": False,
"company_id": self.m1.id,
"class_id": self.ref("pms.pms_room_type_class_0"),
}
)
@@ -597,6 +620,7 @@ class TestRoomTypeCodePropertyUniqueness(TestRoomType):
"code_type": "c1",
"pms_property_ids": [(6, 0, [self.p1.id])],
"company_id": False,
"class_id": self.ref("pms.pms_room_type_class_0"),
}
)
r2 = self.env["pms.room.type"].create(
@@ -605,6 +629,7 @@ class TestRoomTypeCodePropertyUniqueness(TestRoomType):
"code_type": "c1",
"pms_property_ids": False,
"company_id": self.m2.id,
"class_id": self.ref("pms.pms_room_type_class_0"),
}
)
@@ -643,6 +668,7 @@ class TestRoomTypeCodePropertyUniqueness(TestRoomType):
"code_type": "c1",
"pms_property_ids": [(6, 0, [self.p1.id])],
"company_id": False,
"class_id": self.ref("pms.pms_room_type_class_0"),
}
)
# r2
@@ -652,6 +678,7 @@ class TestRoomTypeCodePropertyUniqueness(TestRoomType):
"code_type": "c1",
"pms_property_ids": False,
"company_id": self.m1.id,
"class_id": self.ref("pms.pms_room_type_class_0"),
}
)
r3 = self.env["pms.room.type"].create(
@@ -660,6 +687,7 @@ class TestRoomTypeCodePropertyUniqueness(TestRoomType):
"code_type": "c1",
"pms_property_ids": False,
"company_id": False,
"class_id": self.ref("pms.pms_room_type_class_0"),
}
)