From 449d24d951070834486252944659c543526c0b49 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, 4 Nov 2025 19:34:25 +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 --- yuthon_property/models/yuthon_property.py | 2 +- .../models/inherit_yuthon_property.py | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/yuthon_property/models/yuthon_property.py b/yuthon_property/models/yuthon_property.py index e1e4f9448..7745d597f 100644 --- a/yuthon_property/models/yuthon_property.py +++ b/yuthon_property/models/yuthon_property.py @@ -59,7 +59,7 @@ class YuthonProperty(models.Model): suite_area = fields.Float(string="套内面积", digits=(16, 4)) purpose_id = fields.Many2one('yuthon.resource.purpose', string="管理类型", compute="compute_information_fields", store=True) admin_id = fields.Many2one('res.users', string="片区管理员", compute="compute_information_fields", store=True) - lessee_id = fields.Many2one('property.tenant.information', string='承租方') + lessee_id = fields.Many2one('property.tenant.information', string='承租方', compute="_compute_lessee_id") title_address = fields.Many2one('yuthon.property.message', string="产权地址", compute="_compute_title_information_fields", store=True) company_id = fields.Many2one('yuthon.property.company', string="公司", compute="compute_information_fields", store=True) rental_address = fields.Text(string="出租地址") diff --git a/yuthon_property_approval/models/inherit_yuthon_property.py b/yuthon_property_approval/models/inherit_yuthon_property.py index 46415a997..0031e9cdd 100644 --- a/yuthon_property_approval/models/inherit_yuthon_property.py +++ b/yuthon_property_approval/models/inherit_yuthon_property.py @@ -106,6 +106,18 @@ class YuthonProperty(models.Model): property_contract_ids = fields.One2many('property.contract.line', 'yuthon_property_id', string="关联物业合同明细行") + @api.depends('property_contract_ids') + def _compute_lessee_id(self): + today = date.today() + for record in self: + contract_lines = record.property_contract_ids + valid_lines = contract_lines.filtered( + lambda line: + line.start_time <= today and + (not line.end_date or line.end_date >= today) + ) + record.lessee_id = valid_lines[0].lessee_id if valid_lines else False + def get_yuthon_property_time(self): unique_property_ids = set() for record in self.search([('property_state', '=', 'to'), ('property_contract_ids', '=', False)]):