[FIX] stock: package transfer shows related pickings

Use case to reproduce:
- Create a picking with a package
- Go to the source or destination package
- Click on package transfers
-> It displays all the pickings

This happens because the package transfer button calls
the all picking tree view that display them.

This commit use an action instead that will add a domain
on it in order to only display the pickings that used the
selected package.

opw-774013
This commit is contained in:
amoyaux
2017-10-10 14:26:35 +02:00
parent b1ce2dd6c1
commit 64237aa3ab
2 changed files with 13 additions and 2 deletions
+11
View File
@@ -694,6 +694,17 @@ class QuantPackage(models.Model):
raise UserError(_('Everything inside a package should be in the same location'))
return True
@api.multi
def action_view_related_picking(self):
""" Returns an action that display the picking related to this
package (source or destination).
"""
self.ensure_one()
pickings = self.env['stock.picking'].search(['|', ('pack_operation_ids.package_id', '=', self.id), ('pack_operation_ids.result_package_id', '=', self.id)])
action = self.env.ref('stock.action_picking_tree_all').read()[0]
action['domain'] = [('id', 'in', pickings.ids)]
return action
@api.multi
def unpack(self):
for package in self:
+2 -2
View File
@@ -176,8 +176,8 @@
</header>
<sheet>
<div class="oe_button_box" name="button_box">
<button class="oe_stat_button" name="%(action_picking_tree_all)d"
string="Package Transfers" type="action"
<button class="oe_stat_button" name="action_view_related_picking"
string="Package Transfers" type="object"
widget="statinfo" icon="fa-dropbox"/>
<button name="get_content_package" type="object" string="View Contained Packages content" icon="fa-cogs" attrs="{'invisible': [('children_ids','=',[])]}"/>
</div>