[FIX] account delay draft opening entry

Before: in the accounting dashboard setup, an opening move was created in step 1 (accounting periods) and step 4 (chart of accounts)

Now: the opening move is only created in step 4 only when a first opening debit/credit is entered manually by our user.

Task-ID #3177315

closes odoo/odoo#122818

X-original-commit: c3793357d823273cb4297b0eb31308ad73a9dff8
Signed-off-by: Nicolas Viseur (vin) <vin@odoo.com>
This commit is contained in:
Ali Alfie (alal)
2023-05-29 14:51:55 +02:00
parent aa128cfd50
commit 2b9587aad6
2 changed files with 6 additions and 4 deletions
+6
View File
@@ -2,6 +2,7 @@
from odoo import api, fields, models, _, tools
from odoo.osv import expression
from odoo.exceptions import UserError, ValidationError
from odoo.tools.float_utils import float_is_zero
from bisect import bisect_left
from collections import defaultdict
import re
@@ -451,6 +452,11 @@ class AccountAccount(models.Model):
either 'debit' or 'credit', depending on which one of these two fields
got assigned.
"""
# only set the opening debit/credit if the amount is not zero,
# otherwise return early
if float_is_zero(amount, precision_digits=2):
return
self.company_id.create_op_move_if_non_existant()
opening_move = self.company_id.account_opening_move_id
-4
View File
@@ -420,7 +420,6 @@ class ResCompany(models.Model):
def setting_init_fiscal_year_action(self):
""" Called by the 'Fiscal Year Opening' button of the setup bar."""
company = self.env.company
company.create_op_move_if_non_existant()
new_wizard = self.env['account.financial.year.op'].create({'company_id': company.id})
view_id = self.env.ref('account.setup_financial_year_opening_form').id
@@ -444,9 +443,6 @@ class ResCompany(models.Model):
if company.opening_move_posted():
return 'account.action_account_form'
# Otherwise, we create the opening move
company.create_op_move_if_non_existant()
# Then, we open will open a custom tree view allowing to edit opening balances of the account
view_id = self.env.ref('account.init_accounts_tree').id
# Hide the current year earnings account as it is automatically computed