diff --git a/addons/account/models/account_account.py b/addons/account/models/account_account.py index 3037e5c4daf..c2ba19ed75a 100644 --- a/addons/account/models/account_account.py +++ b/addons/account/models/account_account.py @@ -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 diff --git a/addons/account/models/company.py b/addons/account/models/company.py index 39ae357f5ba..1da178c3ee9 100644 --- a/addons/account/models/company.py +++ b/addons/account/models/company.py @@ -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