如何使odoo自定义股票移动(odoo v8和v9)



我正在创建一个自定义模块。有一个一对多的场。它有-

数量

计量单位

源位置

目标位置

我需要把产品从产地转移到目的地。

在odoo v8中我看到了两个函数

def do_detailed_transfer(self)

do_transfer()

但是do_detailed_transfer在odoo v9中不可用

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

谢谢。

我能够创建股票移动与以下代码-

        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

我正在测试你的代码,我得到了一个错误'对象没有属性'requisition_items',或employee_id,产品一定是我漏掉了什么重要的东西,你可以告诉我下面是我的代码:

# -*- coding: utf-8 -*-

from openerp import models, fields, api

class add_fields_envase(models.Model): _inherit = 'sale.order.line'

articulo =  fields.Many2one('product.product', 'Articulo')
cantidad1 =  fields.Integer('Cantidad',default=0)
@api.onchange('envases1')
def new_move_stock(self):
    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

最新更新