生产单根据BOM计算出相应的物料需求,生产领料单stock.picking ( internal moves)

Stock.picking使用工作流自动计算库存量,如果库存量够,则使用 test_assigned() 将 picking的状态切换到 assigned

test_assigned()调用 stock.check_assign() 计算库存量是否够

 
 

如果原材料库存量不够,生产单就会处于 confirmed 状态,而不能进入 assigned状态

子工作流

 
 

使用force reservation按钮之后,系统会把picking对应的stock.move预留下来,这样就可以完成移库操作;如工作流所示

 
 

picking状态为 assigned的,就是可以完成picking的文档

 
 

而stock.move状态的改变,会影响到'产品可用数量'

 
 

模型 stock.move

 
 

def check_assign(self, cr, uid, ids, context=None):

""" Checks the product type and accordingly writes the state.

@return: No. of moves done

"""

done = []

count = 0

pickings = {}

if context is None:

context = {}

for move in self.browse(cr, uid, ids, context=context):

if move.product_id.type == 'consu' or move.location_id.usage == 'supplier':

if move.state in ('confirmed', 'waiting'):

done.append(move.id)

pickings[move.picking_id.id] = 1

continue

if move.state in ('confirmed', 'waiting'):

# Important: we must pass lock=True to _product_reserve() to avoid race conditions and double reservations

res = self.pool.get('stock.location')._product_reserve(cr, uid, [move.location_id.id], move.product_id.id, move.product_qty, {'uom': move.product_uom.id}, lock=True)

if res:

#_product_available_test depends on the next status for correct functioning

#the test does not work correctly if the same product occurs multiple times

#in the same order. This is e.g. the case when using the button 'split in two' of

#the stock outgoing form

self.write(cr, uid, [move.id], {'state':'assigned'})

done.append(move.id)

pickings[move.picking_id.id] = 1

r = res.pop(0)

product_uos_qty = self.pool.get('stock.move').onchange_quantity(cr, uid, ids, move.product_id.id, r[0], move.product_id.uom_id.id, move.product_id.uos_id.id)['value']['product_uos_qty']

move.write({

'location_id': r[1],

'product_qty': r[0],

'product_uos_qty': product_uos_qty,

})

 
 

while res:

r = res.pop(0)

product_uos_qty = self.pool.get('stock.move').onchange_quantity(cr, uid, ids, move.product_id.id, r[0], move.product_id.uom_id.id, move.product_id.uos_id.id)['value']['product_uos_qty']

move_id = self.copy(cr, uid, move.id, {'product_uos_qty': product_uos_qty, 'product_qty': r[0], 'location_id': r[1]})

done.append(move_id)

if done:

count += len(done)

self.write(cr, uid, done, {'state': 'assigned'})

 
 

if count:

for pick_id in pickings:

wf_service = netsvc.LocalService("workflow")

wf_service.trg_write(uid, 'stock.picking', pick_id, cr)

return count

 
 

 
 

模型 product.product

def _product_available(self, cr, uid, ids, field_names=None, arg=False, context=None):

""" Finds the incoming and outgoing quantity of product.

@return: Dictionary of values

"""

if not field_names:

field_names = []

if context is None:

context = {}

res = {}

for id in ids:

res[id] = {}.fromkeys(field_names, 0.0)

for f in field_names:

c = context.copy()

if f == 'qty_available':

c.update({ 'states': ('done',), 'what': ('in', 'out') })

if f == 'virtual_available':

c.update({ 'states': ('confirmed','waiting','assigned','done'), 'what': ('in', 'out') })

if f == 'incoming_qty':

c.update({ 'states': ('confirmed','waiting','assigned'), 'what': ('in',) })

if f == 'outgoing_qty':

c.update({ 'states': ('confirmed','waiting','assigned'), 'what': ('out',) })

stock = self.get_product_available(cr, uid, ids, context=c)

for id in ids:

res[id][f] = stock.get(id, 0.0)

return res

 
 

模型 mrp.production

def force_production(self, cr, uid, ids, *args):

""" Assigns products.

@param *args: Arguments

@return: True

"""

pick_obj = self.pool.get('stock.picking')

pick_obj.force_assign(cr, uid, [prod.picking_id.id for prod in self.browse(cr, uid, ids)])

return True

 
 

 
 

 
 

模型 stock.picking

def force_assign(self, cr, uid, ids, *args):

""" Changes state of picking to available if moves are confirmed or waiting.

@return: True

"""

wf_service = netsvc.LocalService("workflow")

for pick in self.browse(cr, uid, ids):

move_ids = [x.id for x in pick.move_lines if x.state in ['confirmed','waiting']]

self.pool.get('stock.move').force_assign(cr, uid, move_ids)

wf_service.trg_write(uid, 'stock.picking', pick.id, cr)

return True

 
 

 
 

模型 stock.move

def force_assign(self, cr, uid, ids, context=None):

""" Changes the state to assigned.

@return: True

"""

self.write(cr, uid, ids, {'state': 'assigned'})

wf_service = netsvc.LocalService('workflow')

for move in self.browse(cr, uid, ids, context):

if move.picking_id:

wf_service.trg_write(uid, 'stock.picking', move.picking_id.id, cr)

return True

 
 

 
 

 
 

工作流 -生产单 -调用拣货子流程

 
 

 
 

 
 

工作流 -拣货单

 
 

 
 

MRP Force Reservation的作用的更多相关文章

  1. [转帖]直击案发现场!TCP 10倍延迟的真相是?

    直击案发现场!TCP 10倍延迟的真相是? http://zhuanlan.51cto.com/art/201911/605268.htm 内核参数调优 非常重要啊. 什么是经验?就是遇到问题,解决问 ...

  2. D3.js 力导向图的制作

    力导向图中每一个节点都受到力的作用而运动,这种是一种非常绚丽的图表. 力导向图(Force-Directed Graph),是绘图的一种算法.在二维或三维空间里配置节点,节点之间用线连接,称为连线. ...

  3. 王者荣耀是怎样炼成的(三)unity组件与脚本

    转载请注明出处:http://www.cnblogs.com/yuxiuyan/p/7565345.html 上回书说到了unity的基本操作.这回我们来侃侃unity中的组件与脚本. 目录结构 一. ...

  4. TCP的发送系列 — 发送缓存的管理(一)

    主要内容:TCP发送缓存的初始化.动态调整.申请和释放. 内核版本:3.15.2 我的博客:http://blog.csdn.net/zhangskd 数据结构 TCP对发送缓存的管理是在两个层面上进 ...

  5. 力导向图Demo

    <html> <head> <meta charset="utf-8"> <title>力导向图</title> < ...

  6. d3实现的力向导图

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  7. Mac OS下面安装mysql以及mysql常用命令

    使用brew安装mysql brew install mysql 安装成功后使用下面命令启动/关闭服务 brew services start mysql brew services stop mys ...

  8. D3.js系列——布局:饼状图和力导向图

    一.饼状图 在布局的应用中,最简单的就是饼状图. 1.数据 有如下数据,需要可视化: , , , , ]; 这样的值是不能直接绘图的.例如绘制饼状图的一个部分,需要知道一段弧的起始角度和终止角度,这些 ...

  9. 被严重误会?APS系统没有想象的那么复杂

    APS的出现要从90年代了,但到现在,很多行业内的顾问或用户提到APS都马上想到的是“要求很精确”“难度很大”“脱离实际”“太理想化”“工作量太大”等等,然后把它束之高阁不睬. 在这里,给大家分析一下 ...

随机推荐

  1. PAT Basic 1037

    1037 在霍格沃茨找零钱 如果你是哈利·波特迷,你会知道魔法世界有它自己的货币系统 —— 就如海格告诉哈利的:“十七个银西可(Sickle)兑一个加隆(Galleon),二十九个纳特(Knut)兑一 ...

  2. PAT Basic 1029

    1029 旧键盘 旧键盘上坏了几个键,于是在敲一段文字的时候,对应的字符就不会出现.现在给出应该输入的一段文字.以及实际被输入的文字,请你列出肯定坏掉的那些键. 输入格式: 输入在2行中分别给出应该输 ...

  3. JQuery中xxx is not a function或者can not find $

    在项目中,遇到以上两个错误,反复折腾了好久,js代码写得没有问题,jquery的文件也引入了,就是反复的报告错误,xxx is not a function.如图: 就是这样的错误,shake is ...

  4. xshell连接linux

    一些命令和快捷键: Ctrl + Alt 切换linux和windows的鼠标 Ctrl + c 或 Ctrl + d退出>状态 在xshell终端输入exit,退出与linux服务器的连接 登 ...

  5. java 位向量

    public class BitVectory { private int count; private int[] a; private static final int BIT_LEN = 32; ...

  6. luogu2604 [ZJOI2010]网络扩容

    先做一遍普通的dinic 然后再更改源点为超级源,超级源向原源加一条capacity=k && cost=0的边,再加上有费用的边跑最小费用最大流 #include <iostr ...

  7. Centos6.5搭建git远程仓库

    远程仓库搭建 step1:安装git ```yum -y install git``` step2:创建用户git,用来运行git服务 useradd git passwd git //修改git用户 ...

  8. MySQL容量规划之tcpcopy应用之道

    官方文档:https://github.com/session-replay-tools/mysql-replay-module tcpcopy可以将正式环境上来自客户端的请求复制一份到测试端并复现, ...

  9. linux的自启动服务脚本的(/etc/rc.d/init.d或者其链接/etc/init.d)

    转载地址:http://www.cnblogs.com/diyunpeng/archive/2009/11/11/1600886.html Linux有自己一套完整的启动体系,抓住了linux启动的脉 ...

  10. Java面向对象三大特征

    封装: 首先,属性可用来描述同一类事物的特征, 行为可描述一类事物可做的操作,封装就是要把属于同一类事物的共性(包括属性与行为)归到一个类中,以方便使用.比如人这个东东,可用下面的方式封装:人{ 年龄 ...