[FIX] stock: select picking type deterministically

The default order on `sequence` was not specific enough,
causing semi-random selection of picking type and warehouse
when several types exist with the same sequence.

The problem was made more likely by the fact that
warehouses create their own picking types.
The algorithm to determine the sequences for the
new types was not handling properly the case of
a NULL sequence.

The patch fixes both issues: the selection of the
default picking type (e.g. for purchase orders),
and the algorithm for choosing the sequence for
new picking types.
This commit is contained in:
Olivier Dony
2016-09-05 18:02:43 +02:00
parent b54ffcc0e7
commit ad50d13b6a
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ from odoo.exceptions import UserError
class PickingType(models.Model):
_name = "stock.picking.type"
_description = "The picking type determines the picking view"
_order = 'sequence'
_order = 'sequence, id'
name = fields.Char('Picking Type Name', required=True, translate=True)
color = fields.Integer('Color')
+1 -1
View File
@@ -188,7 +188,7 @@ class Warehouse(models.Model):
color = available_colors and available_colors[0] or 0
# suit for each warehouse: reception, internal, pick, pack, ship
max_sequence = PickingType.search_read([], ['sequence'], limit=1, order='sequence desc')
max_sequence = PickingType.search_read([('sequence', '!=', False)], ['sequence'], limit=1, order='sequence desc')
max_sequence = max_sequence and max_sequence[0]['sequence'] or 0
warehouse_data = {}