From 31a5bd3883a94f7e4156d6453dffc9ce8c466f40 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, 10 Mar 2026 11:34:07 +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 | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/yuthon_property_approval/models/property_lease_contract.py b/yuthon_property_approval/models/property_lease_contract.py index d88c07773..fa5498c24 100644 --- a/yuthon_property_approval/models/property_lease_contract.py +++ b/yuthon_property_approval/models/property_lease_contract.py @@ -2014,10 +2014,19 @@ class PropertyLeaseContract(models.Model): if self.admin_id: self.users_id = self.admin_id.user_id.id + @api.onchange("actual_start_time", "actual_end_time", "term_end_time") + def _onchange_actual_start_time(self): + for record in self: + record.contract_time() + def get_property_contract_time(self): records_only_in_tree1 = self.env['property.lease.contract'].search([('state', '!=', 'settle')]) + for record in records_only_in_tree1: + record.contract_time() + + def contract_time(self): today = fields.Date.today() - for contract in records_only_in_tree1: + for contract in self: # 获取时间字段 actual_start = contract.actual_start_time actual_end = contract.actual_end_time @@ -2032,7 +2041,6 @@ class PropertyLeaseContract(models.Model): else: # 如果不是最后一天,生效月份为当月 effective_month = fields.Date.to_date(f"{actual_end.year}-{actual_end.month}-01") - # 根据时间条件更新状态 if not actual_start or today < actual_start: # 待执行:实际开始时间未到或未设置