I am on odoo 11 but I think for 8 it is the same. In my use case I wanted to reduce the amount of a product when the stage of my custom model is set to 'done'. Inventory amount is changed by stock.move and stock.move.line. So what I did is creating a stock.move and linked a stock.move.line to it when the state changes to 'done'.
Examples of stock.move creation can be found in addons/stock/tests/test_move.py
Here is a recipe:
1. If you do not yet have a location, create one
<record id="location_mylocation" model="stock.location">
<field name="name">MyLocation</field>
<field name="location_id" ref="stock.stock_location_locations_virtual"/>
<field name="usage">inventory</field>
<field name="company_id"></field>
</record>
The usage is set to 'inventory' to reduce the amount of the product. Scrap Orders use the same mechanism.
2. Create a stock.move
move = self.env['stock.move'].create({
'name': 'Use on MyLocation',
'location_id': stock_location.id,
'location_dest_id': mylocation.id,
'product_id': product.id,
'product_uom': product.uom_id.id,
'product_uom_qty': qty,
})
move._action_confirm()
move._action_assign()
move.move_line_ids.write({'qty_done': qty}) # This creates a stock.move.line record. You could also do it manually
move._action_done()
hope these customization tips will hlep: https://sites.google.com/view/thinkincode/erp/odoo