In the implementation process, encountered a problem, I hope that production planners can not see in addition to the production of other internal location, but the lack can not affect the production staff in the normal receipt of the warehouse.
The first thought is to use rule to control access to the location, rule objects can not be mrp.production can only be stock.location, otherwise the restrictions on location_src_id and location_dest_id do not work.
can only be limited by the rule of stock.location, but the problem is that although the production can not see the other internal location, but not from other location, receive, send the item.
As a result, the Location control module which is linked with the permission group is opened, and the setting of the Management permission group can be specified in the location setting, and then the dynamic domain is used to filter the location dynamically in the location of the production single place.
then, in the production of overloaded fields_view_get methods, the dynamic filtering of the location is implemented:
1 ifNot context:context={}2res = super (qunar_mrp,self). Fields_view_get (cr,uid,view_id,view_type,context=context,toolbar=toolbar,submenu=submenu)3Doc = etree. XML (res['Arch'])4nodes = Doc.xpath ("//field[@name = ' location_src_id ')")5ids =self._get_default_location_ids (Cr,uid,context)6 forNodeinchnodes:7Node.Set('Domain',"[' usage ', ' = ', ' internal '), (' id ', ' in ',"+str (IDS) +")]")8 9Dnodes = Doc.xpath ("//field[@name = ' location_dest_id ')")Ten forNodeinchDnodes: OneNode.Set('Domain',"[' usage ', ' = ', ' internal '), (' id ', ' in ',"+str (IDS) +")]") A -res['Arch'] =etree.tostring (DOC) - returnRes
the effect of the implementation is as follows:
Dynamic filtering of production source location and destination location