From ef0139de1e10dc867bdc7add2e5484d34f8bbe60 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: Fri, 5 Sep 2025 18:16: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/inherit_hr_leave_allocation.py | 6 +++ .../inherit_hr_leave_allocation_views.xml | 7 +++ .../wizard/property_reconciliation_wizard.py | 44 ++++++++++++++----- 3 files changed, 47 insertions(+), 10 deletions(-) diff --git a/yuthon_holiday/models/inherit_hr_leave_allocation.py b/yuthon_holiday/models/inherit_hr_leave_allocation.py index 2070d4983..fb307668e 100644 --- a/yuthon_holiday/models/inherit_hr_leave_allocation.py +++ b/yuthon_holiday/models/inherit_hr_leave_allocation.py @@ -84,6 +84,12 @@ class HrLeaveAllocation(models.Model): for leave in leave_ids: leave.write({'state': 'refuse'}) + def all_validate(self): + leave_ids = self.env["hr.leave.allocation"].browse( + self._context.get('active_ids', self._context.get('active_id'))) + for leave in leave_ids: + leave.write({'state': 'validate'}) + def action_uninstall_wizard(self): return { diff --git a/yuthon_holiday/views/inherit_hr_leave_allocation_views.xml b/yuthon_holiday/views/inherit_hr_leave_allocation_views.xml index cb327f5bb..4983aa643 100644 --- a/yuthon_holiday/views/inherit_hr_leave_allocation_views.xml +++ b/yuthon_holiday/views/inherit_hr_leave_allocation_views.xml @@ -55,6 +55,13 @@ code action = model.all_refuse() + + 批量批准 + + + code + action = model.all_validate() + 初始化假期 diff --git a/yuthon_property_approval/wizard/property_reconciliation_wizard.py b/yuthon_property_approval/wizard/property_reconciliation_wizard.py index bf48db2a1..fe88c29b9 100644 --- a/yuthon_property_approval/wizard/property_reconciliation_wizard.py +++ b/yuthon_property_approval/wizard/property_reconciliation_wizard.py @@ -148,18 +148,42 @@ class PropertyReconciliationWizard(models.Model): if all_penalties and self.reconciliation_line_ids: total = sum(line.rent for line in self.reconciliation_line_ids) self.receivable_total = total - self.create_reconciliation_vals() - target_rent_months = [] + + all_due_dates = [] for line in self.reconciliation_line_ids: - if line.collection_type == 'rent' and line.amount == 0: - # 提取到期日期的年月(作为分组依据) - due_month = fields.Date.from_string(line.due_date).strftime('%Y-%m') - target_rent_months.append({ - 'contract_id': line.contract_id, - 'property_id': line.property_id, - 'due_month': due_month # 待补违约金的年月 - }) + if line.collection_type == 'rent' and line.due_date: + all_due_dates.append(fields.Date.from_string(line.due_date)) + # 2. 找到最早的到期日期 + if all_due_dates: + earliest_due_date = min(all_due_dates) + # 3. 计算最早日期的下个月(作为分组起始月) + if earliest_due_date.month == 12: + next_month_of_earliest = earliest_due_date.replace(year=earliest_due_date.year + 1, month=1, day=1) + else: + next_month_of_earliest = earliest_due_date.replace(month=earliest_due_date.month + 1, day=1) + + temp_rent_set = set() + target_rent_months = [] + for line in self.reconciliation_line_ids: + if line.collection_type == 'rent': + due_month = next_month_of_earliest.strftime('%Y-%m') + unique_key = ( + line.contract_id.id if line.contract_id else None, + line.property_id.id if line.property_id else None, + due_month + ) + if unique_key not in temp_rent_set: + temp_rent_set.add(unique_key) + target_rent_months.append({ + 'contract_id': line.contract_id, + 'property_id': line.property_id, + 'due_month': due_month + }) + else: + # 没有符合条件的明细行时,返回空列表 + target_rent_months = [] + if target_rent_months: existing_penalty_months = set() for line in self.reconciliation_line_ids: