Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet

I am trying to unlink account.move.line through wizard on a button but error is getting called as "unbalanced entry debit - credit", Below is my code and screenshot of error for reference.
I can understand it wants to delete the journal items too , but how to do it?

def confirm(self):
if not self.move_lines:
raise UserError(_("Please check no any lines Available in wizard."))
move_lines = self.move_lines.filtered(lambda line: line.select_item == True)
for line in move_lines:
line.move_line_id.unlink()
return {'type': 'ir.actions.act_window_close'}


Avatar
Verwerfen
Beste Antwort

Hi,

Please try the below code using check_move_validity=False in context

def confirm(self):
if not self.move_lines:
raise UserError(_("Please check no any lines Available in wizard."))
move_lines = self.move_lines.filtered(lambda line: line.select_item == True)
for line in move_lines:
line.move_line_id.with_context(check_move_validity=False).unlink()
return {'type': 'ir.actions.act_window_close'}


Hope this will help you

Thanks


Avatar
Verwerfen
Autor

Hey thankyou buddy, It worked.

Verknüpfte Beiträge Antworten Ansichten Aktivität
0
Apr. 23
3024
1
Okt. 22
5593
2
März 22
4527
2
März 22
7040
0
Juni 24
3125