[IMP] assert that move is balanced, recompute amount total, and set reconciled to false to avoid having a null value instead

This commit is contained in:
Sébastien BEAU
2018-03-20 22:52:51 +01:00
committed by Yannick Vaucher
parent cbe947b196
commit 2543c027b8

View File

@@ -249,6 +249,7 @@ class AccountJournal(models.Model):
'balance_cash_basic': values['debit'] - values['credit'],
'ref': move.ref,
'user_type_id': account.user_type_id.id,
'reconciled': False,
})
values = move_line_obj._add_missing_default_values(values)
return values
@@ -323,6 +324,11 @@ class AccountJournal(models.Model):
self._write_extra_move_lines(parser, move)
if self.create_counterpart:
self._create_counterpart(parser, move)
# Check if move is balanced
move.assert_balanced()
# Computed total amount of the move
move._amount_compute()
# Attach data to the move
attachment_data = {
'name': 'statement file',
'datas': file_stream,