odoo销售模块中的库存移动

Quotation的状态为SALES ORDER时,sheet的顶端会显示一个小车的图标,打开开发者模式的情况下将鼠标移到小车上,会显示delivery_count字段,全局搜索这个字段,发现它位于在sale_stock模块中继承的Sale.Order模型里,在其对应的xml里搜索此字段,得到小车只能按钮所调用的方法。

下面通过注释解释这个方法:

    @api.multi
    def action_view_delivery(self):
        '''
        This function returns an action that display existing delivery orders
        of given sales order ids. It can either be a in a list or in a form
        view, if there is only one delivery order to show.
        '''
        action = self.env.ref('stock.action_picking_tree_all').read()[0]  # 获取全部分拣单
        # picking_ids = fields.One2many('stock.picking', 'sale_id', string='Pickings')
        pickings = self.mapped('picking_ids')  # 获取记录集里与本次销售订单相关的分拣单
        if len(pickings) > 1:  # 如果获取到的分拣单数大于1,就过滤出id在当前记录集里的记录显示
            # domain (optional):
            # filtering domain to implicitly add to all view search queries
            action['domain'] = [('id', 'in', pickings.ids)]
        elif pickings:  # 如果只有一个分拣单,就以form视图显示它
            # views:
            # a list of (view_id, view_type) pairs.
            # The second element of each pair is the category of the view (tree, form, graph, …) and the first is an
            # optional database id (or False). If no id is provided, the client should fetch the default view of the
            # specified type for the requested model (this is automatically done by fields_view_get()). The first type
            # of the list is the default view type and will be open by default when the action is executed. Each view
            # type should be present at most once in the list
            action['views'] = [(self.env.ref('stock.view_picking_form').id, 'form')]
            # res_id (optional):
       
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值