跳至內容
選單
此問題已被標幟

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'}


頭像
捨棄
最佳答案

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


頭像
捨棄
作者

Hey thankyou buddy, It worked.

相關帖文 回覆 瀏覽次數 活動
0
4月 23
3058
1
10月 22
5607
2
3月 22
4541
2
3月 22
7086
0
6月 24
3176