From f9e93327af3b0f67f5a7e2e552111850f26c5fde Mon Sep 17 00:00:00 2001 From: "Tiffany Chang (tic)" Date: Thu, 23 Nov 2023 17:39:43 +0100 Subject: [PATCH] [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 --- addons/stock/models/stock_picking.py | 2 +- addons/stock/tests/test_stock_flow.py | 22 ---------------------- 2 files changed, 1 insertion(+), 23 deletions(-) diff --git a/addons/stock/models/stock_picking.py b/addons/stock/models/stock_picking.py index 2e173d5634f..58756805671 100644 --- a/addons/stock/models/stock_picking.py +++ b/addons/stock/models/stock_picking.py @@ -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', diff --git a/addons/stock/tests/test_stock_flow.py b/addons/stock/tests/test_stock_flow.py index 303caae1760..448c7a744ac 100644 --- a/addons/stock/tests/test_stock_flow.py +++ b/addons/stock/tests/test_stock_flow.py @@ -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({