[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:
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user