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

Hi,

I'm trying to create a new sale order line from a custom module but I'm getting this error:

`convert amount from unknown company`



This is the code I'm using:

order_line.sudo().create([{'product_id': itemId,
'product_uom_qty': quantity,
'order_id': orderId}])

I tried passing company_id and currency_id, and I'm getting the same error.


PD: The order has company_id and currency_id filled.

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

The problem was sudo() is deprecated, I changed with with_user(1), and now is working.

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

Hey David,

Warning says, there might be some issue with the company_id or currency_id though its getting filled. Try passing the company_id and currency_id to the dict.

order_line.sudo().create([{'product_id': itemId,
'product_uom_qty': quantity,
'order_id': orderId,
'company_id': lambda self: self.env.user.company.id,
'currency_id': lambda self: self.env.company.currency_id.id
}])

Thanks & Regards,

Email: odoo@aktivsoftware.com

Skype: kalpeshmaheshwari

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ส.ค. 21
6865
1
พ.ย. 20
4004
0
เม.ย. 24
1084
0
ธ.ค. 23
2019
odoo 14 werkzeug.posixemulation error แก้ไขแล้ว
4
ต.ค. 23
14982