diff --git a/l10n_it_declaration_of_intent/models/account_move.py b/l10n_it_declaration_of_intent/models/account_move.py index fef619f1d133..163f235e5d63 100644 --- a/l10n_it_declaration_of_intent/models/account_move.py +++ b/l10n_it_declaration_of_intent/models/account_move.py @@ -230,7 +230,7 @@ def check_declarations_amounts(self, declarations): declarations_residual = sum( [declarations_amounts[da] for da in declarations_amounts] ) - if declarations_residual < 0: + if self.currency_id.compare_amounts(declarations_residual, 0) == -1: raise UserError( _("Available plafond insufficent.\n" "Excess value: %s") % (abs(declarations_residual)) @@ -242,7 +242,12 @@ def check_declarations_amounts(self, declarations): declaration = declaration_model.browse(declaration_id) # declarations_amounts contains residual, so, if > limit_amount, # used_amount went < 0 - if declarations_amounts[declaration_id] > declaration.limit_amount: + if ( + self.currency_id.compare_amounts( + declarations_amounts[declaration_id], declaration.limit_amount + ) + == 1 + ): excess = abs( declarations_amounts[declaration_id] - declaration.limit_amount )