diff --git a/addons/stock/i18n/stock.pot b/addons/stock/i18n/stock.pot index d728eb27bed..799122c9d68 100644 --- a/addons/stock/i18n/stock.pot +++ b/addons/stock/i18n/stock.pot @@ -7651,13 +7651,6 @@ msgstr "" msgid "Sequence picking" msgstr "" -#. module: stock -#. odoo-python -#: code:addons/stock/models/stock_picking.py:0 -#, python-format -msgid "Sequences %s already exist." -msgstr "" - #. module: stock #: model:ir.model.fields,field_description:stock.field_stock_move__lot_ids msgid "Serial Numbers" diff --git a/addons/stock/models/stock_picking.py b/addons/stock/models/stock_picking.py index fad1004cf14..2e173d5634f 100644 --- a/addons/stock/models/stock_picking.py +++ b/addons/stock/models/stock_picking.py @@ -343,16 +343,6 @@ class PickingType(models.Model): for record in self: record.show_picking_type = record.code in ['incoming', 'outgoing', 'internal'] - @api.constrains('sequence_id') - def _check_sequence_code(self): - domain = expression.OR([[('company_id', '=', record.company_id.id), ('name', '=', record.sequence_id.name)] - for record in self]) - duplicate_records = self.env['ir.sequence']._read_group( - domain, ['company_id', 'name'], having=[('__count', '>', 1)]) - if duplicate_records: - duplicate_names = [name for __, name in duplicate_records] - raise UserError(_("Sequences %s already exist.", - ', '.join(duplicate_names))) class Picking(models.Model): _name = "stock.picking" diff --git a/addons/stock/tests/__init__.py b/addons/stock/tests/__init__.py index 9cfe78269f6..ceed79b5c47 100644 --- a/addons/stock/tests/__init__.py +++ b/addons/stock/tests/__init__.py @@ -22,6 +22,5 @@ from . import test_report_stock_quantity from . import test_report_tours from . import test_stock_return_picking from . import test_stock_lot -from . import test_picking from . import test_picking_tours from . import test_replenish diff --git a/addons/stock/tests/test_picking.py b/addons/stock/tests/test_picking.py deleted file mode 100644 index f581d767573..00000000000 --- a/addons/stock/tests/test_picking.py +++ /dev/null @@ -1,34 +0,0 @@ -from odoo.tests import common -from odoo.exceptions import UserError - -class TestPicking(common.TransactionCase): - - def test_00_no_duplicate_sequence_code(self): - stock_location = self.env.ref('stock.stock_location_stock') - operation_type_1 = self.env['stock.picking.type'].create({ - 'name':'test 1', - 'code': 'internal', - 'default_location_src_id':stock_location.id, - 'default_location_dest_id':stock_location.id, - 'sequence_code':'testpicking' - }) - with self.assertRaises(UserError) as er: - self.env['stock.picking.type'].create({ - 'name':'test 2', - 'code': 'internal', - 'default_location_src_id':stock_location.id, - 'default_location_dest_id':stock_location.id, - 'sequence_code':'testpicking' - }) - self.assertEqual( - er.exception.args[0], f'Sequences {operation_type_1.sequence_id.name} already exist.') - - def test_empty_picking_draft(self): - """ test an empty still can be reset to draft """ - picking = self.env['stock.picking'].create({ - 'picking_type_id': self.env.ref('stock.picking_type_in').id, - 'location_id': self.env.ref('stock.stock_location_stock').id, - 'location_dest_id': self.env.ref('stock.stock_location_stock').id, - }) - self.assertFalse(picking.move_ids) - self.assertEqual(picking.state, 'draft') diff --git a/addons/stock/tests/test_stock_flow.py b/addons/stock/tests/test_stock_flow.py index a6eaff54b2e..303caae1760 100644 --- a/addons/stock/tests/test_stock_flow.py +++ b/addons/stock/tests/test_stock_flow.py @@ -2507,6 +2507,16 @@ class TestStockFlow(TestStockCommon): 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({ + 'picking_type_id': self.picking_type_in, + 'location_id': self.stock_location, + 'location_dest_id': self.stock_location, + }) + self.assertFalse(picking.move_ids) + self.assertEqual(picking.state, 'draft') + @tagged('-at_install', 'post_install') class TestStockFlowPostInstall(TestStockCommon):