From 2dc2c20fe59200c4dde66f1a0662669ef1f12f1a Mon Sep 17 00:00:00 2001 From: Laurent Smet Date: Tue, 26 Nov 2019 09:54:17 +0000 Subject: [PATCH] [FIX] account: Fix missing dependencies of _check_duplicate_supplier_reference - Create a vendor bill for partner A with reference 'AAAAA' - Create another vendor bill for partner A with the same reference: => Constraint is triggered. - Create another vendor bill without partner with the same reference. - Edit the vendor bill and set a partner: => Constraint not triggered. closes odoo/odoo#40897 X-original-commit: 3f6254c8faa7dfb2484f4ac18d4c0fd717149e4b Signed-off-by: oco-odoo --- addons/account/models/account_move.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 5a21e336d86..748fb5b1586 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -1339,7 +1339,7 @@ class AccountMove(models.Model): if res: raise ValidationError(_('Posted journal entry must have an unique sequence number per company.')) - @api.constrains('ref') + @api.constrains('ref', 'type', 'partner_id', 'journal_id', 'invoice_date') def _check_duplicate_supplier_reference(self): moves = self.filtered(lambda move: move.is_purchase_document() and move.ref) if not moves: