Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
2 Відповіді
4156 Переглядів

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
7280
1
лист. 20
4291
0
квіт. 24
1274
0
груд. 23
2314
4
лип. 25
15325