[FIX] stock: show operations view and planned pickings

According to the planned_picking context key (which is set by the plan a
picking button), the detailed operations page should be visible or not.
This commit is contained in:
Simon Lejeune
2017-09-22 19:30:16 +02:00
parent b42547e7f7
commit 0b30f6aec4
2 changed files with 14 additions and 3 deletions
+13 -2
View File
@@ -288,12 +288,23 @@ class Picking(models.Model):
'changing the done quantities.')
# Used to search on pickings
product_id = fields.Many2one('product.product', 'Product', related='move_lines.product_id')
show_operations = fields.Boolean(related='picking_type_id.show_operations')
show_operations = fields.Boolean(compute='_compute_show_operations')
_sql_constraints = [
('name_uniq', 'unique(name, company_id)', 'Reference must be unique per company!'),
]
@api.depends('picking_type_id.show_operations')
def _compute_show_operations(self):
for picking in self:
if picking.picking_type_id.show_operations:
if (picking.state == 'draft' and not self.env.context.get('planned_picking')) or picking.state != 'draft':
picking.show_operations = True
else:
picking.show_operations = False
else:
picking.show_operations = False
@api.depends('move_type', 'move_lines.state', 'move_lines.picking_id')
@api.one
def _compute_state(self):
@@ -381,7 +392,7 @@ class Picking(models.Model):
@api.depends('state', 'move_lines')
def _compute_show_mark_as_todo(self):
for picking in self:
if not self.move_lines:
if not picking.move_lines:
picking.show_mark_as_todo = False
elif self._context.get('planned_picking') and picking.state == 'draft':
picking.show_mark_as_todo = True
+1 -1
View File
@@ -254,7 +254,7 @@
</group>
</group>
<notebook>
<page string="Detailed Operations" attrs="{'invisible': ['|', '&amp;', ('show_operations', '=', True), ('state', '=', 'draft'), ('show_operations', '=', False)]}">
<page string="Detailed Operations" attrs="{'invisible': [('show_operations', '=', False)]}">
<field name="move_line_ids" context="{'default_picking_id': id, 'default_location_id': location_id, 'default_location_dest_id': location_dest_id}">
<tree editable="bottom" decoration-muted="result_package_id" decoration-danger="qty_done&gt;product_uom_qty" decoration-success="qty_done==product_uom_qty and state!='done' and not result_package_id">
<field name="product_id" required="1"/>