_# jeffery # focus on Odoo and other open source IT solutions # IT基础架构资深专家,开源解决方案专家,odoo资深专家__Q:913547235 讨论群397750860

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

   

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 的信息 发送邮件,所以选择如下

   

   

posted on 2016-03-29 21:59  odoouse  阅读(922)  评论(0编辑  收藏  举报

导航

_# jeffery # focus on Odoo and other open source IT solutions # IT基础架构资深专家,开源解决方案专家,odoo资深专家