I have 2 model: Contract & Room.
In model room I have a selection field to set state for room.
They are my model:
- Room:
class PmaApartmentRoom(models.Model):
_inherit = "pma.apartment.room"
contract = fields.One2many("pma.contract", "room", string="Contract")
state = fields.Selection([
("available", "Available"),
("rented", "Rented")],
string="Status", copy=False,
index=True, readonly=True, store=True, tracking=True)
class PmaContract(models.Model):
_name = "pma.contract"
_inherit = ["mail.thread", "mail.activity.mixin"]
_description = "Manage contract"
state = fields.Selection([
("draft", "Draft"),
("to_link", "To link"),
("active", "Active"),
("expired", "Expired"),
("liquidated", "Liquidated")],
string="Status", default="draft", copy=False,
index=True, readonly=True, store=True, tracking=True,)
room = fields.Many2one("pma.apartment.room", string="Room name", domain="[('apartment', '=', apartment)]", ondelete="restrict", store=True, required=True, tracking=True)
State of contract = "active" => state of room = "rented".
State of contract in ["draft", "to_link", "expried", "liquidated"] => state of room = "available"
Please help me ....