[FIX] account: default_get aml compute balance
Create an account.move, create a line, then add an item to start to add a second aml The current balance of the move is put in debit (or credit) to help automatically making the second line Save the move. Edit the move Delete a line Add a new line Before this commit, the balance was not correctly computed because the default_get did not compute the balance on deleted lines The move ended up with wrong unbalanced new lines After this commit, the balance is computed with deleted lines taken into account
This commit is contained in:
@@ -475,8 +475,11 @@ class AccountMoveLine(models.Model):
|
||||
#compute the default credit/debit of the next line in case of a manual entry
|
||||
balance = 0
|
||||
for line in self._context['line_ids']:
|
||||
if line[2]:
|
||||
if line[2]: # in case of command 0: add a record with values
|
||||
balance += line[2].get('debit', 0) - line[2].get('credit', 0)
|
||||
elif line[0] == 2: # line has been deleted
|
||||
line_obj = self.browse(line[1])
|
||||
balance -= line_obj.debit - line_obj.credit
|
||||
if balance < 0:
|
||||
rec.update({'debit': -balance})
|
||||
if balance > 0:
|
||||
|
||||
Reference in New Issue
Block a user