1
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user