Skip to Content
Menu
This question has been flagged
1 Reply
3620 Views

I've created products(model product.template), using Odoo API but when I tried setting the product.template's id, Odoo didn't let me and set the id with a value generated by the system.

final Integer id = (Integer)models.execute("execute_kw", Arrays.asList(
                        db, uid, password,
                        "product.template", "create",
                        Arrays.asList(new HashMap() {{ 
                                                       put("is_published", true);
                                                       put("active", true);
                                                       put("x_standartization_level", article.getStandartizationLevel());
                                                       put("id", Integer.valueOf(article.getMfsIdentifier()));
Avatar
Discard
Best Answer

Odoo will set the ID for all the records of the tables defined automatically. You don't have to specify the ID explicitly.

Avatar
Discard
Author

Yes, Odoo sets the ids for all the records.

But i need to set the product ids with the values of the ids of my objects.

The web service loads list of articles into Odoo.

For each article the service creates a product(product.template) on Odoo.

Each object article contains a list of related articles(object article).

In product.template i created a field Related articles, the type-many2many, referencing product.template.

Odoo created a join table with two fields article id and related article id.

So, when i'm creating the products, i need to know the ids of the article

so that i can set the relations between article and related article into the join table,

if Odoo generates the ids i cannot set the relations into the join table.

Do you think that it is possible to set the id of a model on Odoo, using the Odoo API?

Thanks