콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
5799 화면

When I try to add same product multiple time in sale order line, how can I merge all of them in a same sale order line by increasing the quantity only?

아바타
취소
작성자

Thank you.

베스트 답변

Try with this code.

---------------------------------------------------------

def merge_duplicate_product_lines(self, res):
for line in res.order_line:
if line.id in res.order_line.ids:
line_ids = res.order_line.filtered(lambda m: m.product_id.id == line.product_id.id)
quantity = 0
for qty in line_ids:
quantity += qty.product_uom_qty
line_ids[0].write({'product_uom_qty': quantity,
'order_id': line_ids[0].order_id.id})
line_ids[1:].unlink()

@api.model
def create(self, vals):
res = super(SaleOrder, self).create(vals)
res.merge_duplicate_product_lines(res)

return res

def write(self, vals):
res = super(SaleOrder, self).write(vals)
self.merge_duplicate_product_lines(self)
return res

아바타
취소
작성자

Thank you brother . it's working .

베스트 답변

You can use this module https://apps.odoo.com/apps/modules/17.0/merge_so_line/

아바타
취소
관련 게시물 답글 화면 활동
0
6월 23
2295
1
12월 22
3654
0
4월 22
2813
1
4월 19
6423
2
7월 25
4221