[FIX] stock: avoid duplicating sequence for new picking type
During upgrade, it try to create picking type if not exist like pos type and everytime will create new sequence too for that picking type. during the creation of picking type there is python constraints that raised if same sequence name with same company exist. so to avoid that will check before creating new sequence if already same company sequence exist then update the sequence name with id using copy prefix to easily identify as copy name. closes odoo/odoo#143609 X-original-commit: e16c15b5306f841d8da6ec3e951aff606e377134 Signed-off-by: William Henrotin (whe) <whe@odoo.com>
This commit is contained in:
@@ -354,6 +354,9 @@ class Warehouse(models.Model):
|
||||
else:
|
||||
data[picking_type].update(create_data[picking_type])
|
||||
sequence = IrSequenceSudo.create(sequence_data[picking_type])
|
||||
existing_sequence = IrSequenceSudo.search_count([('company_id', '=', sequence.company_id.id), ('name', '=', sequence.name)], limit=1)
|
||||
if existing_sequence:
|
||||
sequence.name = _("%(name)s (copy)(%(id)s)", name=sequence.name, id=str(sequence.id))
|
||||
values.update(warehouse_id=self.id, color=color, sequence_id=sequence.id)
|
||||
warehouse_data[picking_type] = PickingType.create(values).id
|
||||
|
||||
|
||||
Reference in New Issue
Block a user