Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.
Module: Invoicing
Entity: account.journal
Compute Method: _compute_last_bank_statement
| Inputs | Method | Outputs |
|---|---|---|
|
self.env.cr.execute("""
SELECT journal.id, statement.id
FROM account_journal journal
LEFT JOIN LATERAL (
SELECT id, company_id
FROM account_bank_statement
WHERE journal_id = journal.id
+ AND first_line_index IS NOT NULL
ORDER BY first_line_index DESC
LIMIT 1
) statement ON TRUE
WHERE journal.id = ANY(%s)
AND statement.company_id = ANY(%s)
""", [self.ids, self.env.companies.ids])
last_statements = {journal_id: statement_id for journal_id, statement_id in self.env.cr.fetchall()}
for journal in self:
journal.last_statement_id = self.env['account.bank.statement'].browse(last_statements.get(journal.id))
|
|
