[IMP] account: better logging of unbalanced entry
Display the difference when an unbalanced journal entry is created to help pointing out the source of the issue. opw-2069673 closes odoo/odoo#37145 X-original-commit: d00e3158cd30067f7cc8d524eff81ccd6e620342 Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com> Co-authored-by: jev-odoo <jev@odoo.com>
This commit is contained in:
co-authored by
jev-odoo
parent
7592d609b8
commit
f00d6aaeaf
@@ -3857,6 +3857,12 @@ msgstr ""
|
||||
msgid "Difference between the computed ending balance and the specified ending balance."
|
||||
msgstr ""
|
||||
|
||||
#. module: account
|
||||
#: code:addons/account/models/account_move.py:408
|
||||
#, python-format
|
||||
msgid "Difference debit - credit: "
|
||||
msgstr ""
|
||||
|
||||
#. module: account
|
||||
#: model:ir.model,name:account.model_digest_digest
|
||||
msgid "Digest"
|
||||
|
||||
@@ -430,7 +430,7 @@ class AccountMove(models.Model):
|
||||
# are already done. Then, this query MUST NOT depend of computed stored fields (e.g. balance).
|
||||
# It happens as the ORM makes the create with the 'no_recompute' statement.
|
||||
self._cr.execute('''
|
||||
SELECT line.move_id
|
||||
SELECT line.move_id, ROUND(SUM(debit - credit), currency.decimal_places)
|
||||
FROM account_move_line line
|
||||
JOIN account_move move ON move.id = line.move_id
|
||||
JOIN account_journal journal ON journal.id = move.journal_id
|
||||
@@ -441,8 +441,12 @@ class AccountMove(models.Model):
|
||||
HAVING ROUND(SUM(debit - credit), currency.decimal_places) != 0.0;
|
||||
''', [tuple(self.ids)])
|
||||
|
||||
if self._cr.fetchone():
|
||||
raise UserError(_("Cannot create unbalanced journal entry."))
|
||||
res = self._cr.fetchone()
|
||||
if res:
|
||||
raise UserError(
|
||||
_("Cannot create unbalanced journal entry.") +
|
||||
"\n\n{}{}".format(_('Difference debit - credit: '), res[1])
|
||||
)
|
||||
return True
|
||||
|
||||
@api.multi
|
||||
|
||||
Reference in New Issue
Block a user