[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:
Goffin Simon
2016-11-03 11:34:33 +01:00
parent b9759971b9
commit 76314f0a3b
2 changed files with 13 additions and 0 deletions
+6
View File
@@ -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
+7
View File
@@ -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'})