[IMP] stock: display check availability only when a move can be checked
This commit is contained in:
@@ -268,6 +268,10 @@ class Picking(models.Model):
|
||||
'Has Packages', compute='_compute_has_packages',
|
||||
help='Check the existence of destination packages on move lines')
|
||||
|
||||
show_check_availability = fields.Boolean(
|
||||
compute='_compute_show_check_availability',
|
||||
help='Technical field used to compute whether the check availability button should be shown.')
|
||||
|
||||
owner_id = fields.Many2one(
|
||||
'res.partner', 'Owner',
|
||||
states={'done': [('readonly', True)], 'cancel': [('readonly', True)]},
|
||||
@@ -353,6 +357,16 @@ class Picking(models.Model):
|
||||
break
|
||||
self.has_packages = has_packages
|
||||
|
||||
@api.multi
|
||||
def _compute_show_check_availability(self):
|
||||
for picking in self:
|
||||
has_moves_to_reserve = any(
|
||||
move.state in ('waiting', 'confirmed', 'partially_available') and
|
||||
float_compare(move.product_uom_qty, 0, precision_rounding=move.product_uom.rounding)
|
||||
for move in picking.move_lines
|
||||
)
|
||||
picking.show_check_availability = picking.is_locked and picking.state in ('confirmed', 'waiting') and has_moves_to_reserve
|
||||
|
||||
@api.onchange('picking_type_id', 'partner_id')
|
||||
def onchange_picking_type(self):
|
||||
if self.picking_type_id:
|
||||
|
||||
@@ -201,8 +201,9 @@
|
||||
<form string="Transfer">
|
||||
<header>
|
||||
<field name="is_locked" invisible="1"/>
|
||||
<field name="show_check_availability" invisible="1"/>
|
||||
<button name="action_confirm" attrs="{'invisible': ['|', ('state', '!=', 'draft'), ('id', '=', False)]}" string="Mark as Todo" type="object" class="oe_highlight" groups="base.group_user"/>
|
||||
<button name="action_assign" attrs="{'invisible': ['|', ('state', 'not in', ('confirmed', 'waiting')), ('is_locked', '=', False)]}" string="Check Availability" type="object" class="oe_highlight" groups="base.group_user"/>
|
||||
<button name="action_assign" attrs="{'invisible': [('show_check_availability', '=', False)]}" string="Check Availability" type="object" class="oe_highlight" groups="base.group_user"/>
|
||||
<button name="button_validate" attrs="{'invisible': ['|', ('state', 'not in', ('draft', 'confirmed', 'assigned')), ('is_locked', '=', False)]}" string="Validate" groups="stock.group_stock_user" type="object" class="oe_highlight"/>
|
||||
<button name="do_print_picking" string="Print" groups="stock.group_stock_user" type="object" attrs="{'invisible': ['|', ('state', 'not in', ('assigned', 'partially_available')), ('is_locked', '=', False)]}"/>
|
||||
<button name="%(action_report_delivery)d" string="Print" attrs="{'invisible': ['|', ('state', '!=', 'done'), ('is_locked', '=', False)]}" type="action" groups="base.group_user"/>
|
||||
|
||||
Reference in New Issue
Block a user