diff --git a/stock_move_location/readme/CONTRIBUTORS.rst b/stock_move_location/readme/CONTRIBUTORS.rst index 569d09c17..0e307c893 100644 --- a/stock_move_location/readme/CONTRIBUTORS.rst +++ b/stock_move_location/readme/CONTRIBUTORS.rst @@ -3,3 +3,4 @@ * Sergio Teruel * Joan Sisquella * Jordi Ballester Alomar +* Lois Rilo diff --git a/stock_move_location/tests/test_common.py b/stock_move_location/tests/test_common.py index 04769281c..ee70c0e85 100644 --- a/stock_move_location/tests/test_common.py +++ b/stock_move_location/tests/test_common.py @@ -16,6 +16,12 @@ class TestsCommon(common.SavepointCase): cls.wizard_obj = cls.env["wiz.stock.move.location"] cls.quant_obj = cls.env["stock.quant"] + # Enable multi-locations: + wizard = cls.env['res.config.settings'].create({ + 'group_stock_multi_locations': True, + }) + wizard.execute() + cls.internal_loc_1 = cls.location_obj.create({ "name": "INT_1", "usage": "internal", diff --git a/stock_move_location/tests/test_move_location.py b/stock_move_location/tests/test_move_location.py index 76d3c60e2..be2286571 100644 --- a/stock_move_location/tests/test_move_location.py +++ b/stock_move_location/tests/test_move_location.py @@ -100,7 +100,9 @@ class TestMoveLocation(TestsCommon): """Test planned transfer.""" wizard = self._create_wizard(self.internal_loc_1, self.internal_loc_2) wizard.onchange_origin_location() - wizard.with_context({'planned': True}).action_move_location() + wizard.add_lines() + wizard = wizard.with_context({'planned': True}) + wizard.action_move_location() picking = wizard.picking_id self.assertEqual(picking.state, 'assigned') self.assertEqual(len(picking.move_line_ids), 4) @@ -129,3 +131,20 @@ class TestMoveLocation(TestsCommon): wizard.origin_location_id = self.internal_loc_2 wizard._onchange_destination_location_id() self.assertEqual(len(lines), 3) + + def test_readonly_location_computation(self): + """Test that origin_location_disable and destination_location_disable + are computed correctly.""" + wizard = self._create_wizard(self.internal_loc_1, self.internal_loc_2) + # locations are editable. + self.assertFalse(wizard.origin_location_disable) + self.assertFalse(wizard.destination_location_disable) + # Disable edit mode: + wizard.edit_locations = False + self.assertTrue(wizard.origin_location_disable) + self.assertTrue(wizard.destination_location_disable) + + def test_picking_type_action_dummy(self): + """Test that no error is raised from actions.""" + pick_type = self.env.ref("stock.picking_type_internal") + pick_type.action_move_location() diff --git a/stock_move_location/wizard/stock_move_location.py b/stock_move_location/wizard/stock_move_location.py index cc64a9b02..287b727f8 100644 --- a/stock_move_location/wizard/stock_move_location.py +++ b/stock_move_location/wizard/stock_move_location.py @@ -20,7 +20,9 @@ class StockMoveLocationWizard(models.TransientModel): ('warehouse_id.company_id', '=', company_id)], limit=1).id origin_location_disable = fields.Boolean( - compute='_compute_readonly_locations') + compute="_compute_readonly_locations", + help="technical field to disable the edition of origin location." + ) origin_location_id = fields.Many2one( string='Origin Location', comodel_name='stock.location', @@ -28,7 +30,9 @@ class StockMoveLocationWizard(models.TransientModel): domain=lambda self: self._get_locations_domain(), ) destination_location_disable = fields.Boolean( - compute='_compute_readonly_locations') + compute="_compute_readonly_locations", + help="technical field to disable the edition of destination location." + ) destination_location_id = fields.Many2one( string='Destination Location', comodel_name='stock.location',