[FIX] account: multi-post in order

When we post multiple draft moves at the same time, the numbering should
be done by starting with the oldest one up to the newest.

closes odoo/odoo#41138

X-original-commit: 5b745eb61377e5b4532f2e370f9b1559a9b66c0a
Related: odoo/enterprise#6975
Signed-off-by: Quentin De Paoli (qdp) <qdp@openerp.com>
This commit is contained in:
wan
2019-11-26 09:41:07 +00:00
parent 7c4628b1f4
commit f9a9c1a9f0
@@ -9,10 +9,7 @@ class ValidateAccountMove(models.TransientModel):
def validate_move(self):
context = dict(self._context or {})
moves = self.env['account.move'].browse(context.get('active_ids'))
move_to_post = self.env['account.move']
for move in moves:
if move.state == 'draft':
move_to_post += move
move_to_post = moves.filtered(lambda m: m.state == 'draft').sorted(lambda m: (m.date, m.ref, m.id))
if not move_to_post:
raise UserError(_('There are no journal items in the draft state to post.'))
move_to_post.post()