添加功能

This commit is contained in:
李鹏宇
2025-09-05 18:16:53 +08:00
parent 6ba140597d
commit ef0139de1e
3 changed files with 47 additions and 10 deletions
@@ -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 {
@@ -55,6 +55,13 @@
<field name="state">code</field>
<field name="code">action = model.all_refuse()</field>
</record>
<record id="all_holiday_update_refuse" model="ir.actions.server">
<field name="name">批量批准</field>
<field name="model_id" ref="hr_holidays.model_hr_leave_allocation"/>
<field name="binding_model_id" ref="hr_holidays.model_hr_leave_allocation"/>
<field name="state">code</field>
<field name="code">action = model.all_validate()</field>
</record>
<record id="all_holiday_update_uninstall" model="ir.actions.server">
<field name="name">初始化假期</field>
<field name="model_id" ref="hr_holidays.model_hr_leave_allocation"/>
@@ -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: