From 21c72de22af3c3face591ada4e745cfbc6ddce3a 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, 24 Nov 2025 15:33:09 +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 | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/yuthon_property_approval/models/inherit_yuthon_property.py b/yuthon_property_approval/models/inherit_yuthon_property.py index 6275fbef3..155761170 100644 --- a/yuthon_property_approval/models/inherit_yuthon_property.py +++ b/yuthon_property_approval/models/inherit_yuthon_property.py @@ -325,6 +325,26 @@ class PropertyBankStatements(models.Model): } } + def unbind(self): + statements_ids = self.env["property.bank.statements"].browse( + self._context.get('active_ids', self._context.get('active_id')) + ) + for statement in statements_ids: + if statement.name: + bank_account = self.env['property.bank.line'].search([ + ('bank', '=', statement.name) + ]) + if bank_account.tenant_id: + # 获取需要删除的合同明细行 + lines_to_delete = self.env['property.tenant.line'].search([ + ('tenant_id', '=', bank_account.tenant_id.id), + ('lease_contract_id', 'in', statement.contract_ids.ids) + ]) + # 删除合同明细行 + if lines_to_delete: + lines_to_delete.unlink() + statement.contract_ids = [(5,)] + def contract_penalty(self): statements_ids = self.env['property.bank.statements'].search([('is_put', '=', True)]) for record in statements_ids: