From a79d83e436e5e965d59663d4a06a0f8a62d8f694 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Tue, 19 Sep 2017 12:30:15 +0200 Subject: [PATCH] [FIX] mrp, stock: picking type automatic colors /!\ Should not be forward-ported in saas-18 Fix bug introduced by https://github.com/odoo/odoo/commit/e59c1b49c2d9729e5f7576e1c205701a340f9396: When creating picking types, a color is automatically assigned. This color is chosen to be the first available one, or by default 1 (since mentioned commit, as '1' would be the default gray used in kanban headers). Unfortunately, this was expressed as `color = first or 1`... which will always be 1 since the very first available color is always 0. --- addons/mrp/models/stock_warehouse.py | 2 +- addons/stock/models/stock_warehouse.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/mrp/models/stock_warehouse.py b/addons/mrp/models/stock_warehouse.py index d2e9f28e7b3..01691a27b70 100644 --- a/addons/mrp/models/stock_warehouse.py +++ b/addons/mrp/models/stock_warehouse.py @@ -58,7 +58,7 @@ class StockWarehouse(models.Model): wh_stock_loc = warehouse.lot_stock_id seq = seq_obj.search([('code', '=', 'mrp.production')], limit=1) other_pick_type = picking_type_obj.search([('warehouse_id', '=', warehouse.id)], order = 'sequence desc', limit=1) - color = other_pick_type and other_pick_type.color or 1 + color = other_pick_type.color if other_pick_type else 1 max_sequence = other_pick_type and other_pick_type.sequence or 0 manu_type = picking_type_obj.create({ 'name': _('Manufacturing'), diff --git a/addons/stock/models/stock_warehouse.py b/addons/stock/models/stock_warehouse.py index bb4916e30de..a4c7876cb87 100644 --- a/addons/stock/models/stock_warehouse.py +++ b/addons/stock/models/stock_warehouse.py @@ -188,8 +188,8 @@ class Warehouse(models.Model): # choose the next available color for the operation types of this warehouse all_used_colors = [res['color'] for res in PickingType.search_read([('warehouse_id', '!=', False), ('color', '!=', False)], ['color'], order='color')] - available_colors = [zef for zef in [0, 3, 4, 5, 6, 7, 8, 1, 2] if zef not in all_used_colors] - color = available_colors and available_colors[0] or 1 + available_colors = [zef for zef in [1, 3, 4, 5, 6, 7, 8, 0, 2] if zef not in all_used_colors] + color = available_colors[0] if available_colors else 1 # suit for each warehouse: reception, internal, pick, pack, ship max_sequence = PickingType.search_read([('sequence', '!=', False)], ['sequence'], limit=1, order='sequence desc')