Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
2094 Lượt xem

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


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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


Ảnh đại diện
Huỷ bỏ
Tác giả

Hey thankyou buddy, It worked.

Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 4 23
2882
1
thg 10 22
5444
2
thg 3 22
4390
2
thg 3 22
6802
0
thg 6 24
2859