• odoo 实现三方物流系统库存功能


    物流系统客户下单,会有一次入库过程,这里可以通过配置路线的方式来实现

    1. 客户表中需要设置客户位置为stock
      image

    2. 添加新的路线,规则:
      image
      image

    效果:销售订单确认时会产生入库单:

    image

    关键补货源码:

    @api.multi
        def _action_launch_stock_rule(self):
            """
            Launch procurement group run method with required/custom fields genrated by a
            sale order line. procurement group will launch '_run_pull', '_run_buy' or '_run_manufacture'
            depending on the sale order line product rule.
            """
            precision = self.env['decimal.precision'].precision_get('Product Unit of Measure')
            errors = []
            for line in self:
                if line.state != 'sale' or not line.product_id.type in ('consu','product'):
                    continue
                qty = line._get_qty_procurement()
                if float_compare(qty, line.product_uom_qty, precision_digits=precision) >= 0:
                    continue
    
                group_id = line.order_id.procurement_group_id
                if not group_id:
                    group_id = self.env['procurement.group'].create({
                        'name': line.order_id.name, 'move_type': line.order_id.picking_policy,
                        'sale_id': line.order_id.id,
                        'partner_id': line.order_id.partner_id.id,
                    })
                    line.order_id.procurement_group_id = group_id
                else:
                    # In case the procurement group is already created and the order was
                    # cancelled, we need to update certain values of the group.
                    updated_vals = {}
                    if group_id.partner_id != line.order_id.partner_id:
                        updated_vals.update({'partner_id': line.order_id.partner_id.id})
                    if group_id.move_type != line.order_id.picking_policy:
                        updated_vals.update({'move_type': line.order_id.picking_policy})
                    if updated_vals:
                        group_id.write(updated_vals)
    
                values = line._prepare_procurement_values(group_id=group_id)
                product_qty = line.product_uom_qty - qty
    
                procurement_uom = line.product_uom
                quant_uom = line.product_id.uom_id
                get_param = self.env['ir.config_parameter'].sudo().get_param
                if procurement_uom.id != quant_uom.id and get_param('stock.propagate_uom') != '1':
                    product_qty = line.product_uom._compute_quantity(product_qty, quant_uom, rounding_method='HALF-UP')
                    procurement_uom = quant_uom
    
                try:
                    self.env['procurement.group'].run(line.product_id, product_qty, procurement_uom, line.order_id.partner_id.property_stock_customer, line.name, line.order_id.name, values)
                except UserError as error:
                    errors.append(error.name)
            if errors:
                raise UserError('\n'.join(errors))
            return True
    
  • 相关阅读:
    Linux服务器上监控网络带宽的18个常用命令
    基于anaconda安装cudarray和deeppy模块
    How to Install CUDA on NVIDIA Jetson TX1
    Ubuntu-tegra 修复sudoers误操作产生的没有sudo权限
    caffe安装指南—吐血整理
    二进制和格雷码转换
    liunux下升级python
    Word Break
    Longest Valid Parentheses
    Multiply Strings
  • 原文地址:https://www.cnblogs.com/qianxunman/p/16499423.html
Copyright © 2020-2023  润新知