[FIX] account: prevent invoice line unlink

Nothing prevents the deletion on invoice line at the Python level. Other
modules might give access directly to the invoice lines, and make their
deletion possible when the invoice is not draft.

opw-743154
This commit is contained in:
Nicolas Martinelli
2017-05-16 15:39:03 +02:00
parent 656accfde4
commit efa4f85480
2 changed files with 12 additions and 0 deletions
+6
View File
@@ -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
+6
View File
@@ -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"