【问题标题】:How do you manually update the stock of a product?您如何手动更新产品的库存?
【发布时间】:2018-08-01 11:45:47
【问题描述】:

我创建了一个继承自 saler.order_line 的字段,该字段称为包装(我将容器视为仓库中的产品),但在创建采购订单时,它与我要包装的产品已从库存中扣除,但我无法得到它。我曾尝试覆盖 write 方法,但它失败了。有什么想法吗?

对不起,我的英语不好。

最好的问候,何塞·安东尼奥。

【问题讨论】:

  • 您是否要更新产品的数量?在产品视图中有一个“更新手头数量”按钮
  • 我正在尝试在销售时从库存中减去
  • 您能否向我们展示您尝试覆盖 write 方法的代码?

标签: odoo odoo-8


【解决方案1】:

我在同一订单行中添加了一个可以充当容器的产品,我想参与库存的流动。

modified sale form

 def action_button_confirm(self, context=None):
    zero_price = [x.product_id.name for x in self.order_line]
    zero_env1 = [x.tipo_env_1.name for x in self.order_line]
    context = dict(context or {})
    procurement_obj = self.pool.get('procurement.order')
    sale_line_obj = self.pool.get('sale.order.line')
    res = {}
    Move = self.env['stock.move']
    warehouse = self.env['stock.warehouse']

    item = self.quant_move_item_model.new({'quant': self.quant1.id})
    item.onchange_quant()
    self.assertEquals(item.source_loc, self.quant1.location_id)


    for transfer in self.order_line:
        moves = self.env['stock.move']
        stock_location = self.env['stock.quant'].search([('product_id', '=', transfer.tipo_env_1.id)])
        move = Move.create({
                    'name': transfer.tipo_env_1.name,
                    'product_id': transfer.tipo_env_1.id,
                    'restrict_lot_id': False,
                    'product_uom_qty':transfer.cantidad_1,
                    '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': stock_location.id,
                    'location_dest_id': 1,                          
            })
    return super(sale_order,self).action_button_confirm()

【讨论】:

    猜你喜欢
    • 2019-12-19
    • 1970-01-01
    • 2023-03-10
    • 1970-01-01
    • 2021-03-16
    • 2016-08-21
    • 2023-04-02
    • 2014-08-30
    • 2019-01-01
    相关资源
    最近更新 更多