跳至内容
菜单
此问题已终结
2 回复
10954 查看

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

形象
丢弃
最佳答案

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

Sure, I will be there :) thank you

编写者 最佳答案

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

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

编写者

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

相关帖文 回复 查看 活动
0
3月 18
4112
2
3月 15
10254
1
3月 15
7384
1
1月 23
4908
4
10月 21
23590