Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
1048 มุมมอง

Hi,


I noticed that Odoo let you make returns to the delivery orders, more than once. There is a way to prevent this with an automated action?


Thanks

อวตาร
ละทิ้ง

I have updated the code for v16. Please check it out

คำตอบที่ดีที่สุด

For Odoo v18 


For Odoo v16, you can change the code in the above video as follows



return_id = record.origin_returned_move_id.id
if return_id:
  returns = model.search([('origin_returned_move_id', '=', return_id)])
  if len(returns) > 1:
    raise UserError('There is already a return for this transfer')"


อวตาร
ละทิ้ง
ผู้เขียน

Hi, the logic is perfect, but it doesn't work with Odoo 16.

Can you try it in Odoo 16?

Thanks!

ผู้เขียน

Thanks mate, but the origin field is not the same, here is the correct code:

return_id = record.origin
if return_id:
returns = model.search([('origin', '=', return_id)])
if len(returns) > 1:
raise UserError('There is already a return for this transfer')

Thanks.!!!

Thanks for pointing that out! I appreciate the correction with the origin field.
The code I had may have been an older version, but it worked for me.
Your updated snippet makes sense,Thanks for sharing the insight!

ผู้เขียน

Hi, is working perfect but if i try to make partial orders, when it creates the backorder, triggers the action, because Odoo creates the backorder with the same origin document id.

How can we adapt the code to validate if the origin contains the string "Return of"? whit that, the automated action will only triggers when applies to a return order.

thanks.

ผู้เขียน

Never mind, updated the code as follows:

return_id = record.origin
if "Return of" in return_id:
returns = model.search([('origin', '=', return_id)])
if len(returns) > 1:
raise UserError('There is already a return for this transfer.')

Related Posts ตอบกลับ มุมมอง กิจกรรม
1
เม.ย. 20
2704
3
มิ.ย. 25
2505
1
ม.ค. 25
1484
0
พ.ค. 24
1660
1
มี.ค. 24
1586