Last active
April 22, 2019 21:58
-
-
Save umiphos/329ecb31a176ec5b0b0282f16e10b274 to your computer and use it in GitHub Desktop.
Forced cancellation of an invoice in odoo via server action
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for rec in records: | |
move_id = rec.move_id | |
# move_id.line_ids.remove_move_reconcile() | |
update_posted_state = rec.journal_id.update_posted | |
rec.journal_id.write({'update_posted': True}) | |
# move_id.button_cancel() | |
# This action will delete any move_id that we have | |
rec.action_cancel() | |
rec.write({'state': 'cancel'}) | |
rec.write({'move_id': False}) | |
if move_id.exists(): | |
move_id.unlink() | |
# Uncomment this if you want to delete the invoice | |
#if rec: | |
# rec.unlink() | |
rec.journal_id.write({'update_posted': update_posted_state}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment