@@ -25,4 +18,18 @@
+
+
+ Debit Note
+
+
+
+ form
+ code
+
+if records:
+ action = records.action_debit_note()
+
+
+
diff --git a/addons/account_debit_note/wizard/account_debit_note.py b/addons/account_debit_note/wizard/account_debit_note.py
index 1c02083f4fc..b03addb8d1b 100644
--- a/addons/account_debit_note/wizard/account_debit_note.py
+++ b/addons/account_debit_note/wizard/account_debit_note.py
@@ -33,6 +33,10 @@ class AccountDebitNote(models.TransientModel):
move_ids = self.env['account.move'].browse(self.env.context['active_ids']) if self.env.context.get('active_model') == 'account.move' else self.env['account.move']
if any(move.state != "posted" for move in move_ids):
raise UserError(_('You can only debit posted moves.'))
+ elif any(move.debit_origin_id for move in move_ids):
+ raise UserError(_("You can't make a debit note for an invoice that is already linked to a debit note."))
+ elif any(move.move_type not in ['out_invoice', 'in_invoice', 'out_refund', 'in_refund'] for move in move_ids):
+ raise UserError(_("You can make a debit note only for a Customer Invoice, a Customer Credit Note, a Vendor Bill or a Vendor Credit Note."))
res['move_ids'] = [(6, 0, move_ids.ids)]
return res