From beaa2933775a05a70eaa58f04d385f29dec31047 Mon Sep 17 00:00:00 2001 From: wan Date: Thu, 19 Sep 2019 10:10:18 +0000 Subject: [PATCH] [IMP] account: tell which invoice are duplicated There was no way of knowing which vendor bills were duplicated if you uploaded multiple vendor bills and the warning from _check_duplicate_supplier_reference was raised. closes odoo/odoo#37131 Signed-off-by: Laurent Smet --- addons/account/models/account_move.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 0d66c3cacb1..e0fbfbc1873 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -1295,8 +1295,11 @@ class AccountMove(models.Model): AND move2.id != move.id WHERE move.id IN %s ''', [tuple(moves.ids)]) - if self._cr.fetchone(): - raise ValidationError(_('Duplicated vendor reference detected. You probably encoded twice the same vendor bill/credit note.')) + duplicated_moves = self.browse([r[0] for r in self._cr.fetchall()]) + if duplicated_moves: + raise ValidationError(_('Duplicated vendor reference detected. You probably encoded twice the same vendor bill/credit note:\n%s') % "\n".join( + duplicated_moves.mapped(lambda m: "%(partner)s - %(ref)s - %(date)s" % {'ref': m.ref, 'partner': m.partner_id.display_name, 'date': format_date(self.env, m.date)}) + )) def _check_balanced(self): ''' Assert the move is fully balanced debit = credit.