From e84fb80759866a85eb55a361c3cff2d690693c83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= Date: Sun, 22 Feb 2026 15:36:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=B9=E9=87=8F=E5=88=A0=E9=99=A4=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E7=94=9F=E6=95=88=E6=97=A5=E6=9C=9F=E7=9A=84=E8=AE=B0?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../models/property_tenant_information.py | 32 +++++++++++++++++++ .../property_tenant_information_views.xml | 7 ++++ 2 files changed, 39 insertions(+) diff --git a/yuthon_property/models/property_tenant_information.py b/yuthon_property/models/property_tenant_information.py index 9defc252b..6defe2b09 100644 --- a/yuthon_property/models/property_tenant_information.py +++ b/yuthon_property/models/property_tenant_information.py @@ -48,6 +48,38 @@ class PropertyTenantInformation(models.Model): if bank_id.name == False and bank_id.user == False and bank_id.bank == False: bank_id.unlink() + def batch_delete_invalid_invoicing_lines(self): + """批量删除没有生效日期的开票信息明细记录""" + # 查找所有生效日期为空的开票信息明细 + invalid_lines = self.env['invoicing.information.line'].search([ + ('start_date', '=', False) + ]) + + count = len(invalid_lines) + if count > 0: + invalid_lines.unlink() + return { + 'type': 'ir.actions.client', + 'tag': 'display_notification', + 'params': { + 'title': '删除成功', + 'message': f'已成功删除 {count} 条没有生效日期的开票信息明细记录', + 'type': 'success', + 'sticky': False, + } + } + else: + return { + 'type': 'ir.actions.client', + 'tag': 'display_notification', + 'params': { + 'title': '提示', + 'message': '没有找到需要删除的记录', + 'type': 'info', + 'sticky': False, + } + } + @api.depends('invoicing_ids', 'invoicing_ids.start_date', 'invoicing_ids.end_date', 'invoicing_ids.scope_business', 'invoicing_ids.invoicing_type', 'invoicing_ids.tax_number', 'invoicing_ids.invoicing_begins') diff --git a/yuthon_property/views/property_tenant_information_views.xml b/yuthon_property/views/property_tenant_information_views.xml index d001fc76e..08092fa75 100644 --- a/yuthon_property/views/property_tenant_information_views.xml +++ b/yuthon_property/views/property_tenant_information_views.xml @@ -94,4 +94,11 @@ code action = model.update_tenant_wizard() + + 批量删除无生效日期的开票信息 + + + code + action = env['property.tenant.information'].batch_delete_invalid_invoicing_lines() + \ No newline at end of file