With odoo 10, I wanted to create „stock move“ records by executing python programs from outside odoo. I used the „Web Service API“ method. My python code looks like this:
# store a record in the odoo table "stock_move"
result = models.execute_kw(db,uid, password,'stock.move', 'create',
[{'product_uom': custom_product_uom,
'price_unit': custom_price_unit,
'product_uom_qty': custom_product_uom_qty,
'partner_id': custom_partner_id,
'procure_method': custom_procure_method,
'priority': custom_priority,
'picking_type_id': custom_picking_type_id,
'location_id': custom_location_id,
'sequence': custom_sequence,
'company_id': custom_company_id,
'state': custom_state,
'ordered_qty': custom_ordered_qty,
'create_uid': custom_create_uid,
'partially_available': custom_partially_available,
'propagate': custom_propagate,
'scrapped': custom_scrapped,
'write_uid': custom_write_uid,
'product_id': custom_product_id,
'name': custom_name,
'location_dest_id': custom_location_dest_id,
'to_refund_so': custom_to_refund_so}])
# store a record in the odoo table "stock_quant" for the move to the receiving location
models.execute_kw(db,uid, password,'stock.quant', 'create',
[{'location_id': custom_location_dest_id,
'company_id': custom_company_id,
'cost': custom_cost,
'create_uid': custom_create_uid,
'write_uid': custom_write_uid,
'in_date': custom_in_date,
'product_id': custom_product_id,
'qty': custom_ordered_qty,
'name': custom_name}])
Although the records were created in the corresponding database tables, the stock in the source location (='location_id') wasn’t updated and also the "Moved Quants" weren't displayed in the "Stock Moves" view. I think it’s because the corresponding relationship in the database table “stock_quant_move_rel” with the dataset tuple “move_id” and “quant_id” wasn’t created. I haven’t found any model to create a record in the “stock_quant_move_rel” table.
Any ideas how to create this record or do it in a different way?