From 1e629d1ea75f2e4322f43f305882b0a1f1435508 Mon Sep 17 00:00:00 2001 From: zhou <123@> Date: Fri, 20 Jun 2025 20:23:53 +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 | 16 ++++++++++++++++ .../views/property_lease_contract.xml | 7 +++++++ 2 files changed, 23 insertions(+) diff --git a/yuthon_property_approval/models/property_lease_contract.py b/yuthon_property_approval/models/property_lease_contract.py index 09ef6712c..b821cb539 100644 --- a/yuthon_property_approval/models/property_lease_contract.py +++ b/yuthon_property_approval/models/property_lease_contract.py @@ -488,6 +488,22 @@ class PropertyLeaseContract(models.Model): all_period_rent = record.do_generate_details_core(start_date, first_year_end_date, False) record.first_year_rent = all_period_rent + def all_action_generate_details(self): + property_ids = self.env["property.lease.contract"].browse( + self._context.get('active_ids', self._context.get('active_id'))) + for record in property_ids: + if record.term_start_time and record.term_end_time: + record.write({'breakdown_ids': [(5, 0, 0)]}) + start_date = record.term_start_time + end_date = record.term_end_time + relativedelta(days=1) + record.do_generate_details_core(start_date, end_date, True) + # 计算首年租金 + first_year_end_date = start_date + relativedelta(months=12) + if first_year_end_date > end_date: + first_year_end_date = end_date + all_period_rent = record.do_generate_details_core(start_date, first_year_end_date, False) + record.first_year_rent = all_period_rent + def do_generate_details_core(self, start_date, end_date, write_db=False): all_period_rent = 0 diff --git a/yuthon_property_approval/views/property_lease_contract.xml b/yuthon_property_approval/views/property_lease_contract.xml index 3de445966..df596aa31 100644 --- a/yuthon_property_approval/views/property_lease_contract.xml +++ b/yuthon_property_approval/views/property_lease_contract.xml @@ -857,6 +857,13 @@ code action = model.action_update_contract() + + 更新租金明细 + + + code + action = model.all_action_generate_details() + 更新时间