Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
11027 Lượt xem

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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;
Ảnh đại diện
Huỷ bỏ
Tác giả

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

Tác giả Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ

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 !

Tác giả

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

Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 3 18
4174
2
thg 3 15
10350
1
thg 3 15
7465
1
thg 1 23
4977
4
thg 10 21
23736