From 4b864f6f5e34e5351dafa35a404396d3826cc1c7 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: Mon, 17 Aug 2026 11:59:10 +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_yuthon_property.py | 28 +++++++++++++++++++ .../views/inherit_yuthon_property_views.xml | 1 + 2 files changed, 29 insertions(+) diff --git a/yuthon_property_approval/models/inherit_yuthon_property.py b/yuthon_property_approval/models/inherit_yuthon_property.py index 0a6ea34d0..d4e1a0a24 100644 --- a/yuthon_property_approval/models/inherit_yuthon_property.py +++ b/yuthon_property_approval/models/inherit_yuthon_property.py @@ -1551,6 +1551,34 @@ class PropertyDepositList(models.Model): }) rec.is_push = True + def delete_duplicate_deposit(self): + """删除重复押金:同一合同 + 同一保证金类型只保留最早一条,删除其余""" + deposits = self.env['property.deposit.list'].search([ + ('contract_id', '!=', False), + ('posit_type', '!=', False), + ]) + seen = {} + to_delete = self.env['property.deposit.list'] + for dep in deposits.sorted(key=lambda d: (d.contract_id.id, d.posit_type, d.id)): + key = (dep.contract_id.id, dep.posit_type) + if key in seen: + to_delete |= dep + else: + seen[key] = dep.id + count = len(to_delete) + if to_delete: + to_delete.unlink() + return { + 'type': 'ir.actions.client', + 'tag': 'display_notification', + 'params': { + 'title': '删除重复押金', + 'message': f'已删除 {count} 条重复押金记录' if count else '没有重复的押金记录', + 'type': 'success' if count else 'info', + 'sticky': False, + }, + } + # 管理费 class PropertyManagementList(models.Model): _inherit = 'property.management.list' diff --git a/yuthon_property_approval/views/inherit_yuthon_property_views.xml b/yuthon_property_approval/views/inherit_yuthon_property_views.xml index d8c7fd8f3..8568815e1 100644 --- a/yuthon_property_approval/views/inherit_yuthon_property_views.xml +++ b/yuthon_property_approval/views/inherit_yuthon_property_views.xml @@ -180,6 +180,7 @@