diff --git a/addons/account/i18n/account.pot b/addons/account/i18n/account.pot index a5336193698..9357316cf50 100644 --- a/addons/account/i18n/account.pot +++ b/addons/account/i18n/account.pot @@ -9467,6 +9467,12 @@ msgstr "" msgid "You can not delete a payment that is already posted" msgstr "" +#. module: account +#: code:addons/account/models/account_invoice.py:1360 +#, python-format +msgid "You can only delete an invoice line if the invoice is in draft state." +msgstr "" + #. module: account #: code:addons/account/models/account_payment.py:128 #, python-format diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index e30108c82be..81540697766 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -1354,6 +1354,12 @@ class AccountInvoiceLine(models.Model): """ pass + @api.multi + def unlink(self): + if self.filtered(lambda r: r.invoice_id and r.invoice_id.state != 'draft'): + raise UserError(_('You can only delete an invoice line if the invoice is in draft state.')) + return super(AccountInvoiceLine, self).unlink() + class AccountInvoiceTax(models.Model): _name = "account.invoice.tax" _description = "Invoice Tax"