Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
12039 Vistas

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.

Avatar
Descartar

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.

Autor

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.

Autor

@Waleed Mohsen thanks for sharing your suggestion for the custom module

Autor

@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.

Mejor respuesta

@Fahmida Yeasmin

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.


Avatar
Descartar
Mejor respuesta

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)

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
2
jul 25
1630
0
ene 24
1654
1
nov 23
1858
1
sept 23
2560
0
mar 15
4178