diff options
| author | Joren Van Onder <jov@odoo.com> | 2017-09-15 13:39:51 -0700 |
|---|---|---|
| committer | amoyaux <arm@odoo.com> | 2017-09-20 15:08:34 +0200 |
| commit | 5ae754754f86caee4ecf9ce8de535f59d1cb917f (patch) | |
| tree | 46b1594a27c0db6845981de66876c43acdc86a38 /addons | |
| parent | a2a361f7e084c808e143e446d8ddab2dd35e80d5 (diff) | |
[IMP] stock: display check availability only when a move can be checked
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/stock/models/stock_picking.py | 14 | ||||
| -rw-r--r-- | addons/stock/views/stock_picking_views.xml | 3 |
2 files changed, 16 insertions, 1 deletions
diff --git a/addons/stock/models/stock_picking.py b/addons/stock/models/stock_picking.py index 33d4eeaabd1..c8ff0586d7c 100644 --- a/addons/stock/models/stock_picking.py +++ b/addons/stock/models/stock_picking.py @@ -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: diff --git a/addons/stock/views/stock_picking_views.xml b/addons/stock/views/stock_picking_views.xml index 4405753e081..3dc8dcbb43d 100644 --- a/addons/stock/views/stock_picking_views.xml +++ b/addons/stock/views/stock_picking_views.xml @@ -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"/> |
