[11.0][IMP] stock_move_location:

* fix tests as per latest changes
* extend test as per latest changes
* add little help in technical fields
This commit is contained in:
Lois Rilo
2019-11-20 13:58:34 +01:00
committed by João Marques
parent 1f51887d13
commit c850f4b02d
4 changed files with 33 additions and 3 deletions

View File

@@ -3,3 +3,4 @@
* Sergio Teruel <sergio.teruel@tecnativa.com>
* Joan Sisquella <joan.sisquella@eficent.com>
* Jordi Ballester Alomar <jordi.ballester@eficent.com>
* Lois Rilo <lois.rilo@eficent.com>

View File

@@ -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",

View File

@@ -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()

View File

@@ -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',