From f9a9c1a9f0dd9476ed3a86cf40c170d292e59516 Mon Sep 17 00:00:00 2001 From: wan Date: Tue, 26 Nov 2019 09:41:07 +0000 Subject: [PATCH] [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) --- addons/account/wizard/account_validate_account_move.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/addons/account/wizard/account_validate_account_move.py b/addons/account/wizard/account_validate_account_move.py index 57b1398729a..23ff062a021 100644 --- a/addons/account/wizard/account_validate_account_move.py +++ b/addons/account/wizard/account_validate_account_move.py @@ -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()