How to make an individual stock transfer (odoo v8 and v9)

I am creating a custom module. There is another field. He has

quantity

unit

source location

destination

I need to transfer the product from the source location to the destination.

In odoo v8, I saw two functions -

def do_detailed_transfer(self)

and

do_transfer()

But do_detailed_transfer is not available in odoo v9.

How to create a custom stock move that will transfer products from a source location to a target location for both versions?

Thank.

+1
source share
1 answer

I can create a stock transfer with the following code -

        res = {}
        Move = self.env['stock.move']
        for transfer in self:
            moves = self.env['stock.move']
            for products in transfer.requisition_items:
                move = Move.create({
                    'name': transfer.employee_id.name,
                    'product_id': products.product_id.id,
                    'restrict_lot_id': False,
                    'product_uom_qty': products.delivery_quantity,
                    'product_uom': 1, #TODO: Change the test value 1 to produc_uom
                    'partner_id': 1, #TODO: Change the test value 1 to partner_id
                    'location_id': products.source_location.id,
                    'location_dest_id': products.destination_location.id,
                })
                moves |= move
                moves.action_done()
                products.write({'move_id': move.id, 'state': 'done'})

            res[transfer.id] = move.id
        return res
+2
source

Source: https://habr.com/ru/post/1658648/


All Articles