zoukankan      html  css  js  c++  java
  • 生产源库位和目的库位动态过滤

      实施过程中,碰到一个问题,希望生产计划人员不能看到除生产以外的其他内部库位,但缺又不能影响生产人员在仓库的正常接收货。

      首先想到的是用rule来控制对库位的访问,rule的对象不能是mrp.production只能是stock.location,否则对location_src_id 和location_dest_id的限制不起作用。

    只能用stock.location的rule来限制,但这样的问题是,虽然生产看不到其他内部库位了,却不能从其他库位,接收,发送物料了。

      于是,二开了跟权限组挂钩的库位控制模块,实现了在库位设置中可以指定管理权限组的设置,然后再在生产单的库位处,利用动态domain来实现对库位的动态过滤。

      

      然后在生产重载fields_view_get方法,实现对库位的动态过滤:    

     1      if not context:context={}
     2         res = super(qunar_mrp,self).fields_view_get(cr,uid,view_id,view_type,context=context,toolbar=toolbar,submenu=submenu)
     3         doc = etree.XML(res['arch'])
     4         nodes = doc.xpath("//field[@name='location_src_id']")
     5         ids = self._get_default_location_ids(cr,uid,context)
     6         for node in nodes:
     7             node.set('domain',"[('usage','=','internal'),('id','in',"+str(ids)+")]")
     8 
     9         dnodes = doc.xpath("//field[@name='location_dest_id']")
    10         for node in dnodes:
    11             node.set('domain',"[('usage','=','internal'),('id','in',"+str(ids)+")]")
    12 
    13         res['arch'] = etree.tostring(doc)
    14         return res

       实现的效果如下:

      

  • 相关阅读:
    SpringBoot中添加事务
    隐藏样式
    Mybatis配置解析
    题目1064:反序数------玩转小聪明
    题目1063:整数和
    题目1062:分段函数23333333333333
    题目1060:完数VS盈数------这题做得我想骂人
    题目1059:abc----------就喜欢这样的题
    题目1050:完数-----------runtime error的问题
    题目1049:字符串去特定字符
  • 原文地址:https://www.cnblogs.com/kfx2007/p/4818795.html
Copyright © 2011-2022 走看看