首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使odoo定制库存移动(odoo v8和v9)

如何使odoo定制库存移动(odoo v8和v9)
EN

Stack Overflow用户
提问于 2016-10-24 10:21:06
回答 2查看 1.7K关注 0票数 1

我正在创建一个自定义模块。有一个one2many字段。它已经-

数量 计量单位 源位置 目的地位置

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

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

代码语言:javascript
复制
def do_detailed_transfer(self)

代码语言:javascript
复制
do_transfer()

但是do_detailed_transfer在odoo v9中是不可用的。

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

谢谢。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-10-26 05:50:37

我可以用下面的代码创建股票移动-

代码语言:javascript
复制
        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
EN

Stack Overflow用户

发布于 2018-07-13 10:51:13

我正在测试您的代码,我得到了一个错误‘object没有属性’requisition_ It‘,或者employee_id,产品肯定是我遗漏了一些重要的东西,接下来您可以告诉我这是我的代码:

代码语言:javascript
复制
# -*- coding: utf-8 -*-

from openerp import models, fields, api

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

代码语言:javascript
复制
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
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40215992

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档