diff --git a/yuthon_property_approval/models/inherit_yuthon_property.py b/yuthon_property_approval/models/inherit_yuthon_property.py index 7142d554d..972a01ecf 100644 --- a/yuthon_property_approval/models/inherit_yuthon_property.py +++ b/yuthon_property_approval/models/inherit_yuthon_property.py @@ -468,8 +468,7 @@ 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", @@ -481,33 +480,32 @@ 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: diff --git a/yuthon_property_approval/wizard/property_reconciliation_wizard_views.xml b/yuthon_property_approval/wizard/property_reconciliation_wizard_views.xml index af84716cd..6e1ae0e94 100644 --- a/yuthon_property_approval/wizard/property_reconciliation_wizard_views.xml +++ b/yuthon_property_approval/wizard/property_reconciliation_wizard_views.xml @@ -49,10 +49,10 @@ - - + +