• 仓库打包作业超出分拣单数量时,发警报邮件


       

    Odoo 仓库打包作业 是允许可以 超出分拣单预计的数量。

       

    odoo 库存模块的代码里,修改 _create_extra_moves() 方法

    def _create_extra_moves(self, cr, uid, picking, context=None):

    '''This function creates move lines on a picking, at the time of do_transfer, based on

    unexpected product transfers (or exceeding quantities) found in the pack operations.

    '''

    move_obj = self.pool.get('stock.move')

    operation_obj = self.pool.get('stock.pack.operation')

    moves = []

    for op in picking.pack_operation_ids:

    for product_id, remaining_qty in operation_obj._get_remaining_prod_quantities(cr, uid, op, context=context).items():

    product = self.pool.get('product.product').browse(cr, uid, product_id, context=context)

    if float_compare(remaining_qty, 0, precision_rounding=product.uom_id.rounding) > 0:

    vals = self._prepare_values_extra_move(cr, uid, op, product, remaining_qty, context=context)

    moves.append(move_obj.create(cr, uid, vals, context=context))

    if moves:

    move_obj.action_confirm(cr, uid, moves, context=context)

    return moves

       

    move_obj.create 这个地方 增加一行代码 发送 alert.

       

    使用 odoo automatic Server action rule 就可以 不用 写一行代码 就能实现 此需求。

       

    原理;

    model 的实例在更新的时候,触发一个 Server Action

    对于上面的需求,要求 stock.move 包含 Extra Move: 字样【如果使用的中文,注意使用汉化,未确认?】 的时候, 才触发 Server Action 这个 可以使用 filter 进行过滤。

       

    设置;

    1. 设置一个 filter.

    为了快速、便捷的设置,可以到 stock move 列表,保存一个 filter.

       

    也可以直接在 user- defined filters 里面定义

       

    2. 设置 automatic Server Action rule.

       

       

    Related document model 选择 stock move

    Where to run 选择 on creation

    Filter 选择 前面定义的 Extra_Move

       

    切换到 Actions 页卡增加一个 服务器动作

       

    选择已有的,或者创建一个新的 Server action

       

       

    因为要利用 stock move 的信息 发送邮件,所以选择如下

       

       

    转载注明原作者 /by Jeffery
  • 相关阅读:
    nuget
    C#枚举中使用Flags特性
    情感分析
    docker
    core部署
    脱壳系列_2_IAT加密壳_详细分析(含脚本)
    安全公司-* * * *-面试题:_ 安卓逆向分析分享
    18_ShadowWalker
    17_页面异常接管
    16_TLB与流水线
  • 原文地址:https://www.cnblogs.com/odoouse/p/5334990.html
Copyright © 2020-2023  润新知