Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Set product's company through API

By
Zensel
on 10/15/15, 1:25 PM 516 views

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 ?

Bista Solutions US, Ray Carnes
on 10/15/15, 1:42 PM

I have update the post with that info.

Zensel
on 10/15/15, 2:45 PM

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

Axel Mendoza
on 10/15/15, 2:52 PM

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

Zensel
on 10/15/15, 3:05 PM
0
Zensel
On 3/15/16, 11:40 AM

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.

0

Axel Mendoza

--Axel Mendoza--
10318
| 7 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

Axel Mendoza
On 10/15/15, 2:55 PM
<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.

Zensel
on 10/15/15, 3:06 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 10/15/15, 1:25 PM
Seen: 516 times
Last updated: 3/15/16, 11:42 AM