This commit is contained in:
pengyuthon
2025-10-27 00:26:56 +08:00
parent 189c40a919
commit d115074092
@@ -468,7 +468,8 @@ class PropertyBankStatements(models.Model):
"dialog_size": "extra-large",
"default_order": "due_date desc",
}
self._check_unreconciled_statements(start_time)
# 未知逻辑忘记可能要补充,只能依次对账
# self._check_unreconciled_statements(start_time)
return {
"type": "ir.actions.act_window",
@@ -480,33 +481,33 @@ class PropertyBankStatements(models.Model):
"context": context,
}
def _check_unreconciled_statements(self, current_transaction_time):
"""
检查所有承租方对应的银行账号在property.bank.statements中是否有未对账流水
:param current_transaction_time: 当前交易时间(带时区处理后)
"""
if not self.lessee_ids:
return
bank_accounts = self.env['property.bank.line'].search([
('tenant_id', 'in', self.lessee_ids.ids)
]).mapped('bank')
bank_accounts = [acc for acc in bank_accounts if acc] # 过滤空值
if not bank_accounts:
return
unreconciled = {}
for account in bank_accounts:
# 查询条件:同账号 + 交易时间早于当前 + 未对账
statements = self.env['property.bank.statements'].search([
('name', '=', account),
('start_time', '<', current_transaction_time),
('bank_state', '=', 'not_reconciled'),
('id', '!=', self.id),
])
if statements:
unreconciled[account] = len(statements)
if unreconciled:
raise UserError("存在未对账的历史流水,请优先处理:")
# def _check_unreconciled_statements(self, current_transaction_time):
# """
# 检查所有承租方对应的银行账号在property.bank.statements中是否有未对账流水
# :param current_transaction_time: 当前交易时间(带时区处理后)
# """
# if not self.lessee_ids:
# return
# bank_accounts = self.env['property.bank.line'].search([
# ('tenant_id', 'in', self.lessee_ids.ids)
# ]).mapped('bank')
# bank_accounts = [acc for acc in bank_accounts if acc] # 过滤空值
# if not bank_accounts:
# return
# unreconciled = {}
# for account in bank_accounts:
# # 查询条件:同账号 + 交易时间早于当前 + 未对账
# statements = self.env['property.bank.statements'].search([
# ('name', '=', account),
# ('start_time', '<', current_transaction_time),
# ('bank_state', '=', 'not_reconciled'),
# ('id', '!=', self.id),
# ])
# if statements:
# unreconciled[account] = len(statements)
#
# if unreconciled:
# raise UserError("存在未对账的历史流水,请优先处理")
def button_reconciliation(self):
for record in self: