From fa2b74f81766cfa18bb7b6a708d7e171ff07e309 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= <9664676+pengyuthon@user.noreply.gitee.com> Date: Thu, 26 Mar 2026 16:33:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../models/inherit_yuthon_property.py | 21 +++++++++++++++++-- .../wizard/property_rental_wizard.py | 1 + 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/yuthon_property_approval/models/inherit_yuthon_property.py b/yuthon_property_approval/models/inherit_yuthon_property.py index 4801c9a6e..8e657dc3c 100644 --- a/yuthon_property_approval/models/inherit_yuthon_property.py +++ b/yuthon_property_approval/models/inherit_yuthon_property.py @@ -1082,7 +1082,7 @@ class PropertyRentList(models.Model): tenure_type = fields.Selection(related='contract_id.tenure_type', string="权属类型", store=True) property_address = fields.Text(string="物业信息", compute='get_property_address') contract_sort = fields.Selection([('property', '物业'), ('guanggao', '广告位'),('parking', '停车场'), ('guanzi', '管子间'), ('room', '机房'), ('base_station','基站'), ('other', '其他')], related='contract_id.contract_sort', string="资产类型", index=True) - company_id = fields.Many2one('yuthon.property.company', string="出租方公司", store=True, compute='_compute_admin_id') + company_id = fields.Many2one('yuthon.property.company', string="出租方公司", store=True, compute='_compute_company_id') @api.depends("property_id", "due_date") def _compute_admin_id(self): @@ -1106,7 +1106,24 @@ class PropertyRentList(models.Model): if valid_lines: valid_lines = valid_lines.sorted(key=lambda l: l.start_time, reverse=True) record.admin_id = valid_lines[0].admin_id.id - record.company_id = valid_lines[0].company_id.id + + @api.depends('contract_id', 'due_date') + def _compute_company_id(self): + for record in self: + record.company_id = False + if not record.contract_id: + continue + lessor_lines = record.contract_id.lessor_line + valid_lessor_lines = lessor_lines.filtered( + lambda line: + line.start_date and + line.start_date <= record.due_date and + (not line.end_date or line.end_date >= record.due_date) + ) + if valid_lessor_lines: + record.company_id = valid_lessor_lines[0].lessor_id + else: + record.company_id = record.contract_id.lessor_id or False @api.depends('contract_id') def get_property_address(self): diff --git a/yuthon_property_approval/wizard/property_rental_wizard.py b/yuthon_property_approval/wizard/property_rental_wizard.py index 33496f375..033118b33 100644 --- a/yuthon_property_approval/wizard/property_rental_wizard.py +++ b/yuthon_property_approval/wizard/property_rental_wizard.py @@ -87,6 +87,7 @@ class PropertyRentalWizard(models.Model): "month": self.select_month, }) rent_id._compute_admin_id() + rent_id._compute_company_id() def create_deposit_list(self, record): """封装创建押金记录的逻辑 - 根据合同中的多种押金类型创建多条记录"""