Skip to Content
Menu
This question has been flagged
2 Replies
1825 Views

I'm writing a PHP script using Odoo External API and I've got a model to fill and one of the field I need to create is a one2many. 

So as I've seen in documentation (https://doc.odoo.com/6.0/developer/2_5_Objects_Fields_Methods/methods/#osv.osv.osv.write), I tried to give a list of tuplet : 

$variable= [0,0,['product_id',1, 'product_uom_qty',35.00]];
$models->execute_kw($db, $uid, $password, 'stock.picking', 'write', array($id)
                    array('location_id'=>8, 'name' => 'TEST1', 'move_ids_without_package
                    =>$variable));
The error message :
TypeError: unhashable type: 'list'


I've also tried with an array :


$variable = array(0 => 0,1 => 0, 2 => array('product_id' =>1, 'product_uom_qty' => 35.00));

$models->execute_kw($db, $uid, $password, 'stock.picking', 'write', array($id)
                    array('location_id'=>8, 'name' => 'TEST1',                     'move_ids_without_package=>$variable));


The error message :
TypeError: unhashable type: 'dict'
 

Avatar
Discard
Author Best Answer

Thanks for answering ! 

But what do you mean by keywords ? Because I'm already using field_name as keywords and their values following.  

After your response, I've tried with the following but none is working : 

$variable= [0,0,[['product_id',1], ['product_uom_qty',35.00]]];
$variable= [0,0,[['product_id : 1'], ['product_uom_qty : 35.00']]];
$variable= [0,0,[['product_id', '=', '1'], ['product_uom_qty', '=', '35.00']]];
$variable= [0,0,[['product_id', ':', '1'], ['product_uom_qty', ':', '35.00']]];
Avatar
Discard
Best Answer

The first one is nearly right [0, 0, [inside this list you need the list with keywords],]. You can create many records this way, a list of lists with keywords.

[0, 0, [(list with keywords), (list with keywords), ...]]


Avatar
Discard