[FIX] account: bank_statement: journal accounts not required in reconciliation widget
Use case: click on "reconcile X items" on a journal which doesn't have its default credit or debit account set. Result: Before this commit, a useless traceback popped to the user. After this commit, move lines are searched without taking into account the journal's default accounts for debit or credit OPW 760305 Closes #18485
This commit is contained in:
@@ -300,7 +300,10 @@ class AccountBankStatement(models.Model):
|
||||
#try to assign partner to bank_statement_line
|
||||
stl_to_assign_partner = [stl.id for stl in st_lines_left if not stl.partner_id]
|
||||
refs = list(set([st.name for st in st_lines_left if not stl.partner_id]))
|
||||
if st_lines_left and stl_to_assign_partner and refs:
|
||||
if st_lines_left and stl_to_assign_partner and refs\
|
||||
and st_lines_left[0].journal_id.default_credit_account_id\
|
||||
and st_lines_left[0].journal_id.default_debit_account_id:
|
||||
|
||||
sql_query = """SELECT aml.partner_id, aml.ref, stl.id
|
||||
FROM account_move_line aml
|
||||
JOIN account_account acc ON acc.id = aml.account_id
|
||||
@@ -597,13 +600,14 @@ class AccountBankStatementLine(models.Model):
|
||||
acc_type = "acc.internal_type IN ('payable', 'receivable')" if (self.partner_id or overlook_partner) else "acc.reconcile = true"
|
||||
select_clause = "SELECT aml.id "
|
||||
from_clause = "FROM account_move_line aml JOIN account_account acc ON acc.id = aml.account_id "
|
||||
where_clause = """WHERE aml.company_id = %(company_id)s
|
||||
AND (
|
||||
(aml.statement_id IS NULL AND aml.account_id IN %(account_payable_receivable)s
|
||||
AND aml.payment_id IS NOT NULL)
|
||||
OR
|
||||
("""+acc_type+""" AND aml.reconciled = false)
|
||||
)"""
|
||||
account_clause = ''
|
||||
if self.journal_id.default_credit_account_id and self.journal_id.default_debit_account_id:
|
||||
account_clause = "(aml.statement_id IS NULL AND aml.account_id IN %(account_payable_receivable)s AND aml.payment_id IS NOT NULL) OR"
|
||||
where_clause = """WHERE aml.company_id = %(company_id)s
|
||||
AND (
|
||||
""" + account_clause + """
|
||||
("""+acc_type+""" AND aml.reconciled = false)
|
||||
)"""
|
||||
where_clause = where_clause + ' AND aml.partner_id = %(partner_id)s' if self.partner_id else where_clause
|
||||
where_clause = where_clause + ' AND aml.id NOT IN %(excluded_ids)s' if excluded_ids else where_clause
|
||||
if split:
|
||||
|
||||
Reference in New Issue
Block a user