我正在创建一个自定义模块。有一个one2many字段。它已经-
数量 计量单位 源位置 目的地位置
我需要把产品从产地转移到目的地。
在odoo v8中,我看到了两个函数-
def do_detailed_transfer(self)和
do_transfer()但是do_detailed_transfer在odoo v9中是不可用的。
如何创建一个自定义库存移动,为两个版本将产品从源位置转移到目标位置?
谢谢。
发布于 2016-10-26 05:50:37
我可以用下面的代码创建股票移动-
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发布于 2018-07-13 10:51:13
我正在测试您的代码,我得到了一个错误‘object没有属性’requisition_ It‘,或者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 reshttps://stackoverflow.com/questions/40215992
复制相似问题