如何使odoo自定义库存移动(odoo v8和v9) [英] How to make odoo custom stock move (odoo v8 and v9)

查看:219
本文介绍了如何使odoo自定义库存移动(odoo v8和v9)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个自定义模块.有一个one2many字段.它具有-

I am creating a custom module. There is an one2many field. It has -

数量

计量单位

源位置

目的地位置

我需要将产品从源位置转移到目标位置.

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

在odoo v8中,我看到了两个功能-

In odoo v8 I saw two functions -

def do_detailed_transfer(self)

do_transfer()

但是doodetailed_transfer在odoo v9中不可用.

如何创建自定义库存移动,以将两种版本的产品从源位置转移到目标位置?

How can I create a custom stock move which will transfer products from source location to destination location for both versions?

谢谢.

推荐答案

我可以使用以下代码创建库存变动-

I am able to create stock move with 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

这篇关于如何使odoo自定义库存移动(odoo v8和v9)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆