Skip to content

Commit

Permalink
hr_payroll_cancel: check in journal for update_posted (OCA#464)
Browse files Browse the repository at this point in the history
  • Loading branch information
MiquelRForgeFlow authored and nikul-serpentcs committed Dec 22, 2018
1 parent 6e9ebd8 commit 0a13107
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion hr_payroll_cancel/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Hr Payroll Cancel",
"version": "11.0.1.0.0",
"version": "11.0.1.0.1",
"author": "Vauxoo, Eficent, "
"Serpent Consulting Services Pvt. Ltd.,"
"Odoo Community Association (OCA)",
Expand Down
8 changes: 6 additions & 2 deletions hr_payroll_cancel/models/hr_payroll.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ def action_payslip_cancel(self):
if payslip.refunded_id and payslip.refunded_id.state != 'cancel':
raise ValidationError(_("""To cancel the Original Payslip the
Refunded Payslip needs to be canceled first!"""))
payslip.move_id.button_cancel()
payslip.move_id.unlink()
if payslip.move_id.journal_id.update_posted:
payslip.move_id.button_cancel()
payslip.move_id.unlink()
else:
payslip.move_id.reverse_moves()
payslip.move_id = False

return self.write({'state': 'cancel'})

0 comments on commit 0a13107

Please sign in to comment.