Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2 Replies
10949 Tampilan

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
Buang
Jawaban Terbai

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
Buang
Penulis

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

Penulis Jawaban Terbai

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
Buang

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 !

Penulis

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

Post Terkait Replies Tampilan Aktivitas
0
Mar 18
4109
2
Mar 15
10231
1
Mar 15
7357
1
Jan 23
4903
4
Okt 21
23584