Odoo Help

0

Create product using XMLRPC - PHP, issue with public_categ_ids

By
Fred Cruypennick
on 6/2/16, 9:32 AM 1,722 views

Hi there,

I'm coding a small interface synchronisation between Odoo V9 and other ERP. Everything is working fine except for the public category ids.

Here's my field:

$fields = array( 'name' => 'test', 'default_code' => '1111', 'public_categ_ids' => array( 81 ) );
$odoo->create_product('product.product', $fields);
public function create_product($model, $fields){
$create = $this->ripcord_models->execute_kw($this->db, $this->uid, $this->password, $model, 'create', array( $fields )) ;
}


And here's the result (using xmlrpc debug):

DEBUG? openerp.http.rpc.request: 'name': 'test',

DEBUG? openerp.http.rpc.request: 'default_code': '1111',

DEBUG? openerp.http.rpc.request: 'public_categ_ids': [81],

All other fields are correctly set (name, default_code, etc.) but not the public_categ_ids and i don't have any error....

Do someone has any clue for me?

Thank you

0

Take a look here: https://www.odoo.com/documentation/8.0/reference/orm.html#openerp.models.Model.write

Have you try something like 'public_categ_ids' => array(array(6,0, array( 81 )))   that should generate the equivalent of   ( 'public_categ_ids' = [(6, 0, [81])] )



    $url = "http://127.0.0.1:8069";
$db = "8.0-debug";
$username = "admin";
$password = "admin";
require_once('ripcord.php');
$common = ripcord::client("$url/xmlrpc/2/common");
$uid = $common->authenticate($db, $username, $password, array());
$models = ripcord::client("$url/xmlrpc/2/object");
$vals = array(
array(
'name' => 'test',
'default_code' => '1111',
'public_categ_ids' => array(
array(6,0, array(1))
)
)
);
$create = $models->execute_kw($db, $uid, $password,
'product.product', 'create', $vals
);
echo $create;

Jérémy... I tried... it works!!! it seems exactly similar to my code... anyway... THANK YOU! If you participate to the 2016 odoo days, i'll offer you a good beer :)

Magneticlab Sàrl, Fred Cruypennick
on 6/2/16, 11:50 AM

Sure, I will be there :) thank you

Jérémy Kersten (jke)
on 6/2/16, 11:53 AM
0
Fred Cruypennick
On 6/2/16, 11:10 AM

Hi Jérémy,

Thx for your reply.

I tried with...

'public_categ_ids' => array( array( 0,0, array( 81 ) ) ), error => cannot convert dictionary update sequence element #0 to a sequence

'public_categ_ids' => array(  0,0, array( 81 )  ),  no error, not working

'public_categ_ids' => array(  6,0, array( 81 )  ),  no error, not working


ps. i'm trying to create, not to update products

can you provide simplified php code to regenerate the issue in local ... that will be faster... And what is 81 ? the id of an existing product category ? so it should be 6 ...

Jérémy Kersten (jke)
on 6/2/16, 11:16 AM

Take a look in my previous answer, I have updated with a example which works !

Jérémy Kersten (jke)
on 6/2/16, 11:26 AM

Here you can browse my code: https://bitbucket.org/sp4tz/odoo-sync/src I simplyfied it a bit, so you wont have the ERP source part...

Magneticlab Sàrl, Fred Cruypennick
on 6/2/16, 11:40 AM

Have you try me code from previous answer ?
'public_categ_ids' => array(array(6,0, array( 81 ))) should works !

'cannot convert dictionary update sequence element' was because you try 0 instead of 6 ! 0 take a dict and not a list of id :)

Jérémy Kersten (jke)
on 6/2/16, 11:50 AM

About This Community

This platform 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.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)

Stats

Asked: 6/2/16, 9:32 AM
Seen: 1722 times
Last updated: 6/2/16, 11:10 AM