[REV] stock: Enable the creation of a transfer from a duplicated operation type

This reverts commit 52219871e8d8357044763375f6f5318622e9894e.

Orig PR for ref: odoo/odoo#122838

Fix was ok for the specific bug it fixes, but then it adds the
additional bug of 2 picking types which can have different prefixes
but the same sequence_id. This on its own is not a big deal, except that
when a prefix is changed for one of the picking types, then the sequence
is updated for both picking types and the prefix of the not changed
picking type will not match anymore. For users not in debug mode, this
would be quite confusing since they cannot see that it is the same
sequence in both picking types.

A better solution is to default the sequences + their prefixes to be
different.

Part-of: odoo/odoo#146362
This commit is contained in:
Tiffany Chang (tic)
2023-12-18 23:31:58 +00:00
parent 5c25669ed3
commit f9e93327af
2 changed files with 1 additions and 23 deletions
+1 -1
View File
@@ -29,7 +29,7 @@ class PickingType(models.Model):
sequence = fields.Integer('Sequence', help="Used to order the 'All Operations' kanban view")
sequence_id = fields.Many2one(
'ir.sequence', 'Reference Sequence',
check_company=True, copy=True)
check_company=True, copy=False)
sequence_code = fields.Char('Sequence Prefix', required=True)
default_location_src_id = fields.Many2one(
'stock.location', 'Default Source Location', compute='_compute_default_location_src_id',
-22
View File
@@ -2485,28 +2485,6 @@ class TestStockFlow(TestStockCommon):
pickings.button_validate()
self.assertTrue(all(pickings.mapped(lambda p: p.state == 'done')), "Pickings should be set as done")
def test_pickings_on_duplicated_operation_types(self):
""" Ensure we can create pickings on duplicated operation types without collision in names
Steps:
- Create a picking on an operation type
- Duplicate the operation type
- Create another picking on the duplicated operation type
"""
self.PickingObj.create({
'picking_type_id': self.picking_type_in,
'location_id': self.supplier_location,
'location_dest_id': self.stock_location,
})
duplicated_picking_type = self.env['stock.picking.type'].browse(self.picking_type_in).copy()
picking_2 = self.PickingObj.create({
'picking_type_id': duplicated_picking_type.id,
'location_id': self.supplier_location,
'location_dest_id': self.stock_location,
})
# trigger SQL constraints
self.PickingObj.flush_model()
self.assertEqual(self.PickingObj.search_count([('name', '=', picking_2.name)]), 1)
def test_empty_picking_draft(self):
""" test an empty still can be reset to draft """
picking = self.PickingObj.create({