From 06140601969f0d464b0be5ef8d6e260abcbace06 Mon Sep 17 00:00:00 2001 From: Maxime Chambreuil Date: Mon, 20 Dec 2021 13:49:38 -0600 Subject: [PATCH] base --- pms_base/models/pms_property.py | 18 +++++++++++---- pms_base/views/pms_property.xml | 41 ++++++++++++++++++++++----------- 2 files changed, 42 insertions(+), 17 deletions(-) diff --git a/pms_base/models/pms_property.py b/pms_base/models/pms_property.py index 93aa1c6b0..79ebf297b 100644 --- a/pms_base/models/pms_property.py +++ b/pms_base/models/pms_property.py @@ -34,7 +34,9 @@ class PmsProperty(models.Model): "pms.property", "parent_id", string="Children Property" ) company_id = fields.Many2one(string="Company", comodel_name="res.company") - team_id = fields.Many2one(string="Team", comodel_name="pms.team") + team_id = fields.Many2one( + "pms.team", string="Team", default=lambda self: self._default_team_id() + ) room_ids = fields.One2many( string="Rooms", help="List of rooms in the property.", @@ -85,9 +87,6 @@ class PmsProperty(models.Model): childs_property_count = fields.Integer( "Children Count", compute="_compute_childs_property" ) - team_id = fields.Many2one( - "pms.team", string="Team", default=lambda self: self._default_team_id() - ) floors_num = fields.Integer(string="Floor") unit_floor = fields.Integer(string="Unit Floor") balcony = fields.Boolean(string="Balcony", compute="_compute_balcony", store=True) @@ -111,6 +110,9 @@ class PmsProperty(models.Model): qty_kitchen = fields.Integer( string="Qty Kitchen", compute="_compute_qty_kitchen", store=True ) + qty_bedroom = fields.Integer( + string="Qty Bedroom", compute="_compute_qty_bedroom", store=True + ) @api.depends("property_child_ids") def _compute_childs_property(self): @@ -244,6 +246,14 @@ class PmsProperty(models.Model): ) rec.qty_kitchen = len(rec.room_ids.filtered(lambda x: x.type_id == type_id)) + @api.depends("room_ids") + def _compute_qty_bedroom(self): + for rec in self: + type_id = self.env.ref( + "pms_base.pms_room_type_bed", raise_if_not_found=False + ) + rec.qty_bedroom = len(rec.room_ids.filtered(lambda x: x.type_id == type_id)) + def action_view_childs_property_list(self): action = self.env["ir.actions.actions"]._for_xml_id( "pms_base.action_pms_property" diff --git a/pms_base/views/pms_property.xml b/pms_base/views/pms_property.xml index 7595cc0ea..4638baf1e 100644 --- a/pms_base/views/pms_property.xml +++ b/pms_base/views/pms_property.xml @@ -77,7 +77,10 @@ - + - - - - - - - - - - - - + + + + + + + + + + + + + + +