第一章 调拨

stock.picking

作业

视图引用: stock.view_picking_form

XPAH定位:

<xpath expr="//field[@name='move_ids_without_package']//tree//field[@name='']" position="">
</xpath>

关联的销售订单

调拨单可以关联销售订单(sale.order), 使用的是sale_stock模型中的sale_id字段。

验证按钮 button_validate

验证动作内部调用了_action_done方法来处理库存移动的逻辑。

而调拨的_action_done方法内部调用了stock.move对象的_action_done方法来完成。

def _action_done(self):
    """Call `_action_done` on the `stock.move` of the `stock.picking` in `self`.
    This method makes sure every `stock.move.line` is linked to a `stock.move` by either
    linking them to an existing one or a newly created one.

    If the context key `cancel_backorder` is present, backorders won't be created.

    :return: True
    :rtype: bool
    """
    self._check_company()

    todo_moves = self.move_ids.filtered(lambda self: self.state in ['draft', 'waiting', 'partially_available', 'assigned', 'confirmed'])
    for picking in self:
        if picking.owner_id:
            picking.move_ids.write({'restrict_partner_id': picking.owner_id.id})
            picking.move_line_ids.write({'owner_id': picking.owner_id.id})
    todo_moves._action_done(cancel_backorder=self.env.context.get('cancel_backorder'))
    self.write({'date_done': fields.Datetime.now(), 'priority': '0'})

    # if incoming/internal moves make other confirmed/partially_available moves available, assign them
    done_incoming_moves = self.filtered(lambda p: p.picking_type_id.code in ('incoming', 'internal')).move_ids.filtered(lambda m: m.state == 'done')
    done_incoming_moves._trigger_assign()

    self._send_confirmation_email()
    return True

results matching ""

    No results matching ""