Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
10495 Vistas

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

Avatar
Descartar
Mejor respuesta

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;
Avatar
Descartar
Autor

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 :)

Sure, I will be there :) thank you

Autor Mejor respuesta

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

Avatar
Descartar

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

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

Autor

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

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 :)

Publicaciones relacionadas Respuestas Vistas Actividad
0
mar 18
3648
2
mar 15
9659
1
mar 15
6759
1
ene 23
4516
4
oct 21
22892