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

We sell CO2 cylinders that are exchanged.


We we get a sales order from shopify with a exchange cylinder, i would like Odoo to add a second line item of the same products in a negative quantity.

so we can send out the full cylinder, and can receive a empty one in return.


Is this possible? 


Please share your thoughts

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi,
You can add an automated action inside the database for the same. Set up an automated action, such a way that on meeting certain condition it will create an extra line in order.




The above attached is a sample, you can change the code as per the need

if not env.context.get('skip_iteration'):

  for record in records:

    vals = {

      'product_id': record.product_id.id,

      'product_uom_qty': record.product_uom_qty * -1,

      'price_unit': 1,

      'order_id': record.order_id.id,

    }

    env['sale.order.line'].with_context(skip_iteration=True).create(vals)

Thanks

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

Thank you very much! it works great

is it also possible to replace the product with a consumable version of it? everything is the same except it should be consumable.

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ก.ค. 23
4125
0
พ.ย. 20
2594
0
พ.ย. 20
2615
0
ก.พ. 25
1303
1
ธ.ค. 24
2435