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

Hi, I have configured Odoo with two main (unrelated) companies. I can create products through API, but when I set the company_id to the second company I get an error.

These are the parameters that I am sending:

<struct>
<member><name>name</name>
<value><string>Product name</string></value>
</member>
<member><name>type</name>
<value><string>product</string></value>
</member>
<member><name>state</name>
<value><string>sellable</string></value>
</member>
<member><name>list_price</name>
<value><double>129.99</double></value>
</member>
<member><name>default_code</name>
<value><string>ProductCode</string></value>
</member>
<member><name>ean13</name>
<value><string>ProductEAN</string></value>
</member>
<member><name>standard_price</name>
<value><double>88.92</double></value>
</member>
<member><name>image_medium</name>
<value><string></string></value>
</member>
<member><name>company_id</name>
<value><string>1</string></value>
</member>
</struct>

I have checked that the company ID is right in database table res_company.

And this is the error message that I get:

warning -- ValidateError
Field(s) `uom_id` failed against a constraint: Error: The default Unit of Measure and the purchase Unit of Measure must be in the same category.
How can I set the other company when creating products using the API? Thanks.
อวตาร
ละทิ้ง

Helping you may depend on knowing how you are creating the products. What dictionary are you sending and what value are you sending for the company_id ?

ผู้เขียน

I have update the post with that info.

You are building the xmlrpc request body by yourself, why don't you use an xmlrpc client to do that for you?

ผู้เขียน

I use a PHP xmlrpc client. This is the request that my client generates.

ผู้เขียน คำตอบที่ดีที่สุด

I found out how to set no company, so it is available to all companies. You have to use the boolean false:

<member>
    <name>company_id</name>
    <value><boolean>0</boolean></value>
</member>

But I cannot set a specific company yet.

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด
<member>
    <name>company_id</name>
    <value><string>1</string></value>
</member>

need to be 

<member>
    <name>company_id</name>
    <value><int>1</int></value>
</member>

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

I get the same error message with this.

Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ส.ค. 25
1029
1
ส.ค. 25
1267
2
ก.ค. 25
4082
API xmlrpc - upload pdf bills to account แก้ไขแล้ว
3
ก.ค. 25
1342
2
ก.ค. 25
2454