From fbe37a95ad57a1dec3592aaeeb3726237e2f909e 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: Thu, 25 Jun 2026 11:04:20 +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_bank_statements.py | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/yuthon_property/models/property_bank_statements.py b/yuthon_property/models/property_bank_statements.py index 489ca525b..7807e7b1d 100644 --- a/yuthon_property/models/property_bank_statements.py +++ b/yuthon_property/models/property_bank_statements.py @@ -275,6 +275,34 @@ class ReceivableModifyLine(models.Model): # 兜底:确保 delivered1 总是被赋值 rec.delivered1 = 0 + @api.onchange('reconciliation_date') + def _onchange_reconciliation_date(self): + """修改核销日期时,根据分组情况同步更新应收款的付款日期""" + for record in self: + if not record.receivable_id or not record.reconciliation_date: + continue + + receivable = record.receivable_id + # 查询同一 receivable_id 下的其他修改明细行(排除当前记录) + domain = [('receivable_id', '=', receivable.id), ('management_type_id', '=', record.management_type_id.id), ('id', '!=', record.id.origin)] + existing_lines = self.env['receivable.modify.line'].search(domain) + # 当前组内记录总数(含当前记录) + group_count = len(existing_lines) + 1 + if group_count == 1: + # 一组只有一条记录:直接同步 payout_date + receivable.payout_date = record.reconciliation_date + elif group_count == 2: + # 一组有两条记录:仅当修改前的 reconciliation_date + # 与 receivable 的 payout_date 相同时才同步 + old_reconciliation_date = False + if record.id.origin: + old_reconciliation_date = self.env['receivable.modify.line'].browse( + record.id.origin + ).reconciliation_date + + if old_reconciliation_date == receivable.payout_date: + receivable.payout_date = record.reconciliation_date + remake = fields.Text(related='receivable_id.remark', string='备注', store=False) # lessee_id = fields.Many2one( # "property.tenant.information",