[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 <smetl@users.noreply.github.com>
This commit is contained in:
wan
2019-09-19 10:10:18 +00:00
parent b487537c24
commit beaa293377
+5 -2
View File
@@ -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.