From b7b5ff900517701ae06a9063e0ed920de0e124f1 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: Tue, 22 Sep 2026 18:05:47 +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/property_lease_contract.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/yuthon_property_approval/models/property_lease_contract.py b/yuthon_property_approval/models/property_lease_contract.py index 42938dcd3..a1e99a9cb 100644 --- a/yuthon_property_approval/models/property_lease_contract.py +++ b/yuthon_property_approval/models/property_lease_contract.py @@ -2718,13 +2718,23 @@ class PropertyLeaseContractLine(models.Model): message_unit = fields.Float(related='message_standard_id.amount', string="管理费单价", store=True) evaluate_unit_price = fields.Float(string="评估单价") - @api.depends('address_id', 'address_id.manage_information_ids') + @api.depends('address_id', 'address_id.manage_information_ids', + 'address_id.manage_information_ids.start_time', + 'address_id.manage_information_ids.end_date') def _compute_property_area(self): + today = fields.Date.context_today(self) for line in self: line.property_area = 0.0 - if line.address_id and line.address_id.manage_information_ids: - latest_line = line.address_id.manage_information_ids.sorted('id', reverse=True)[0] - line.property_area = latest_line.rent_area + if not line.address_id: + continue + # 生效日期[start_time] ~ 失效日期[end_date] 覆盖当前日期的管理信息 + valid_lines = line.address_id.manage_information_ids.filtered( + lambda item: (not item.start_time or item.start_time <= today) + and (not item.end_date or item.end_date >= today) + ) + if valid_lines: + # 多条命中时取生效日期最新的一条 + line.property_area = valid_lines.sorted('start_time', reverse=True)[0].rent_area def open_record(self): self.ensure_one()