Sort posted lines to reconcile at last by party
The lines may or may not have a party depending on the account. So the order key must avoid compare party instance with None value. Closes #13268 (grafted from 97e730164485c038de7744ea0a3fb189fd7426fa) --HG-- branch : 7.0
This commit is contained in:
1 parent
d769ff636c
commit
b7adb7ba77
2 files changed
+7
-2
No files matched your search
@@ -504,7 +504,9 @@ class Move(DescriptionOriginMixin, ModelSQL, ModelView):
|
||||
cls.save(moves)
|
||||
|
||||
def keyfunc(line):
|
||||
return line.party, line.account
|
||||
# Set party last to avoid compare party instance and None
|
||||
# party will always be None for the same account
|
||||
return line.account, line.party
|
||||
to_reconcile = Line.browse(sorted(
|
||||
[l for l in Line.browse(to_reconcile) if l.account.reconcile],
|
||||
key=keyfunc))
|
||||
|
||||
@@ -656,12 +656,15 @@ class AccountTestCase(
|
||||
self.assertEqual(move.state, 'posted')
|
||||
|
||||
# Move lines with debit = credit = 0 are automatically reconciled
|
||||
receivable_no_party, = Account.copy([receivable], default={
|
||||
'party_required': False,
|
||||
})
|
||||
move = Move()
|
||||
move.period = period
|
||||
move.journal = journal_revenue
|
||||
move.date = period.start_date
|
||||
move.lines = [
|
||||
Line(account=revenue, credit=Decimal(0)),
|
||||
Line(account=receivable_no_party, credit=Decimal(0)),
|
||||
Line(account=receivable, debit=Decimal(0), party=party),
|
||||
]
|
||||
move.save()
|
||||
|
||||
Reference in new issue
Block a user