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.account
Compute Method: _compute_opening_debit_credit
| Inputs | Method | Outputs |
|---|---|---|
|
self.opening_debit = 0 self.opening_credit = 0 self.opening_balance = 0 - if not self.ids: + opening_move = self.env.company.account_opening_move_id + if not self.ids or not opening_move: return - self.env.cr.execute(""" + self.env.cr.execute(SQL( + """ SELECT line.account_id, SUM(line.balance) AS balance, SUM(line.debit) AS debit, SUM(line.credit) AS credit FROM account_move_line line - JOIN res_company comp ON comp.id = line.company_id - WHERE line.move_id = comp.account_opening_move_id - AND line.account_id IN %s + WHERE line.move_id = %(opening_move_id)s + AND line.account_id IN %(account_ids)s GROUP BY line.account_id - """, [tuple(self.ids)]) + """, + account_ids=tuple(self.ids), + opening_move_id=opening_move.id, + )) result = {r['account_id']: r for r in self.env.cr.dictfetchall()} for record in self: res = result.get(record.id) or {'debit': 0, 'credit': 0, 'balance': 0} record.opening_debit = res['debit'] record.opening_credit = res['credit'] record.opening_balance = res['balance'] |
|
