Skip to Content
Menu
This question has been flagged
4 Replies
17015 Views

Creating a custom module where product gets moved from one location to another. I have two locations - source location and destination location.

How can I call odoo v8 stock move function on button click? So that the product transfers from one location to other.

Avatar
Discard

hope these customization tips will hlep: https://sites.google.com/view/thinkincode/erp/odoo

Best Answer

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()
Avatar
Discard
Best Answer

You Can Download This App With Detailed product Move In and Out 

https://apps.odoo.com/apps/modules/12.0/stock_item_move_report


Avatar
Discard
Best Answer

You can do it without any customization. Ventor app allows you to move items from one location to another. Working on Odoo 8 - Odoo 11. More details on the site - \ventor.tech/ventor-mobile-app-for-odoo-inventory/

Avatar
Discard
Related Posts Replies Views Activity
0
May 21
2278
0
Aug 17
2115
1
May 17
3351
0
Dec 15
2387
0
Sep 15
2172