I have posted an entry for checking how it is working. But unfortunately, I haven't changed the currency in my country. Now I wanted to change the currency and it says it can't be changed as I already have posted entries.
Now I wanted to delete that journal entry. So, please suggest.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
We can edit the posted Journal Entries using write method with context value.(check_move_validity=False)
First cancel the journal entry.
journal_entry_obj.button_cancel()
And Remove the existing line item one2many data and create new records in one2many table in account.move.line. Look at the below code.
for line in journal_entry_obj.line_ids:
# Deleting the line_ids by passing the conlutext value for skipping the crdit and debit validation.
line.sudo().with_context(check_move_validity=False).unlink()
# Updating one2many table data
data_line_dict = {
"move_id": journal_entry_obj.id,
"account_id": account_id,
"partner_id": partner_id,
"name": name,
"debit": debit,
"credit": credit,
"company_id": journal_entry_obj.company_id.id,
"company_currency_id": journal_entry_obj.company_id.currency_id.id,
"currency_id": journal_entry_obj.currency_id.id,
}
self.env['account.move.line'].sudo().with_context(check_move_validity=False).create(data_line_dict)
and finally call the Reset to Draft and Post button
journal_entry_obj.button_draft()
journal_entry_obj.action_post()
It will work.
In Odoo 14.0 you can't delete them but you can add a customization to override unlink method of account.move model as below, so you can develop a custom module and override unlink method and then install it and delete the journal entries and then uninstall it if you don't need it.
from odoo import models
class AccountMove(models.Model):
_inherit = "account.move"
def unlink(self):
for move in self:
move.line_ids.unlink()
return models.Model.unlink(self)
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
0
Jan 24
|
382 | ||
|
0
Nov 23
|
344 | ||
|
1
Nov 23
|
457 | ||
Multiple journal entries
Solved
|
|
1
Sep 23
|
1008 | |
|
0
Mar 15
|
3265 |
What Odoo version you are using? If you are using Odoo 15.0 you can reset the journal to draft and delete it. but in Odoo 14 you can't do that.
Thanks for your answer. Unfortunately, I am using Odoo 14 version.
You will not be able to delete them even if you cancelled them you will not be able to change the main currency. You have a lesson learned to not do any test in Live DB.
See this method: https://www.youtube.com/watch?v=Avo42KGbkKA&t=43s
@Waleed Mohsen thanks for sharing your suggestion for the custom module
@Odoo Mates, thanks for your suggestion. It's really worked with my one entry.
But it isn't working with another entry from the expense app, which I have posted for adding with salary to the payroll.
Please suggest any solution for this.