[FIX] hr_expense: unlink posted expense
Steps to reproduce: - Create one (or several) expense lines - Submit them to the manager (create the expense sheet) - Approve the sheet and post the entries - Delete the created and posted sheet Bug: - The expense is deleted but the accounting entries are still in the database - The expense lines are in "To submit" and you can submit to manager again and generate a new report and therefore new accounting entries... Fix: It is not allowed to delete posted expense. opw:692323
This commit is contained in:
@@ -1249,6 +1249,12 @@ msgid "You can setup a generic email alias to create\n"
|
||||
" in the mail subject to set it on the expense too."
|
||||
msgstr ""
|
||||
|
||||
#. module: hr_expense
|
||||
#: code:addons/hr_expense/models/hr_expense.py:421
|
||||
#, python-format
|
||||
msgid "You cannot delete a posted expense."
|
||||
msgstr ""
|
||||
|
||||
#. module: hr_expense
|
||||
#: code:addons/hr_expense/models/hr_expense.py:105
|
||||
#, python-format
|
||||
|
||||
@@ -417,6 +417,13 @@ class HrExpenseSheet(models.Model):
|
||||
self._add_followers()
|
||||
return res
|
||||
|
||||
@api.multi
|
||||
def unlink(self):
|
||||
for expense in self:
|
||||
if expense.state == "post":
|
||||
raise UserError(_("You cannot delete a posted expense."))
|
||||
super(HrExpenseSheet, self).unlink()
|
||||
|
||||
@api.multi
|
||||
def set_to_paid(self):
|
||||
self.write({'state': 'done'})
|
||||
|
||||
Reference in New Issue
Block a user