From 5ae1b8098458d9443d4f217e6ee1b39d9c637328 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: Wed, 5 Nov 2025 20:07:01 +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_hr_leave_allocation.py | 6 +++--- .../wizard/property_rental_wizard.py | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/yuthon_holiday/models/inherit_hr_leave_allocation.py b/yuthon_holiday/models/inherit_hr_leave_allocation.py index b741f5686..9eb6832d3 100644 --- a/yuthon_holiday/models/inherit_hr_leave_allocation.py +++ b/yuthon_holiday/models/inherit_hr_leave_allocation.py @@ -223,9 +223,9 @@ class HrLeaveAllocation(models.Model): 'vacation_date': date }) - reports_id.write({'leave_ids': leave_list}) - reports_id.write({'overtime_ids': compensatory_list}) - reports_id.write({'other_fee_ids': other_list}) + reports_id.write({'leave_ids': [(5, 0, 0)] + leave_list}) + reports_id.write({'overtime_ids': [(5, 0, 0)] + compensatory_list}) + reports_id.write({'other_fee_ids': [(5, 0, 0)] + other_list}) # def allocation_date(self): # date = datetime(2025, 1, 1) # leave_id = self.env['hr.leave.allocation'].search([]) diff --git a/yuthon_property_approval/wizard/property_rental_wizard.py b/yuthon_property_approval/wizard/property_rental_wizard.py index d7c58f1fd..fa14b8318 100644 --- a/yuthon_property_approval/wizard/property_rental_wizard.py +++ b/yuthon_property_approval/wizard/property_rental_wizard.py @@ -185,8 +185,22 @@ class PropertyRentalWizard(models.Model): adjusted_day = min(start_day, max_day) date_str = f"{date_field_year_month}-{adjusted_day}" start_date = datetime.strptime(date_str, "%Y-%m-%d").date() + # 判断是否是最新合同版本 + new_version = True + all_versions = self.env['property.lease.contract'].search([ + ('contract_code', '=', record.contract_code) + ]) + if all_versions: + version_info = [] + for ver in all_versions: + version_num = float(ver.version.lstrip('Vv')) + version_info.append((ver.id, version_num)) + max_version_id = max(version_info, key=lambda x: x[1])[0] + if record.id != max_version_id: + new_version = False + # 当期应收日期 - if not record.is_contract: + if not record.is_contract and new_version: if start_year_month <= date_field_year_month <= end_year_month: if rent_id.period_rent != 0 and record.contract_sort not in ['guanggao', 'guanzi', 'room']: self.create_rent_list(record, rent_id, rent_amount, start_date, multiplier) @@ -211,6 +225,7 @@ class PropertyRentalWizard(models.Model): records = self.env['property.lease.contract'].search([ ('actual_start_time', '<', next_month_first_day), ('actual_end_time', '>=', first_day), + ('state', '=', 'done') ]) for record in records: # 获取租金乘数(1 表示按月,3 表示季租金,6 表示半年租金,年后面赋值)