mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[IMP] stock_quant_manual_assign: Tests for missing cases
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
|
||||
|
||||
import openerp.tests.common as common
|
||||
from openerp import exceptions
|
||||
|
||||
|
||||
class TestStockQuantManualAssign(common.TransactionCase):
|
||||
@@ -65,6 +66,21 @@ class TestStockQuantManualAssign(common.TransactionCase):
|
||||
self.assertFalse(line.selected)
|
||||
self.assertEqual(wizard.move_qty, self.move.product_uom_qty)
|
||||
|
||||
def test_quant_assign_wizard_constraint(self):
|
||||
wizard = self.quant_assign_wizard.with_context(
|
||||
active_id=self.move.id).create({
|
||||
'name': 'New wizard',
|
||||
})
|
||||
self.assertEqual(len(wizard.quants_lines.ids), 3,
|
||||
'Three quants created, three quants got by default')
|
||||
self.assertEqual(len(wizard.quants_lines.filtered('selected').ids), 0,
|
||||
'None of the quants must have been selected')
|
||||
self.assertEqual(wizard.lines_qty, 0.0,
|
||||
'None selected must give 0')
|
||||
with self.assertRaises(exceptions.ValidationError):
|
||||
wizard.write({'quants_lines': [(1, wizard.quants_lines[:1].id,
|
||||
{'selected': True, 'qty': 500})]})
|
||||
|
||||
def test_quant_manual_assign(self):
|
||||
wizard = self.quant_assign_wizard.with_context(
|
||||
active_id=self.move.id).create({
|
||||
@@ -74,14 +90,24 @@ class TestStockQuantManualAssign(common.TransactionCase):
|
||||
'Three quants created, three quants got by default')
|
||||
wizard.quants_lines[0].write({
|
||||
'selected': True,
|
||||
'qty': 100.0,
|
||||
})
|
||||
wizard.quants_lines[0].onchange_selected()
|
||||
wizard.quants_lines[1].write({
|
||||
'selected': True,
|
||||
'qty': 50.0,
|
||||
})
|
||||
self.assertEqual(wizard.lines_qty, 150.0)
|
||||
self.assertEqual(wizard.move_qty, 250.0)
|
||||
wizard.assign_quants()
|
||||
self.assertEqual(len(wizard.quants_lines.filtered('selected')),
|
||||
len(self.move.reserved_quant_ids))
|
||||
selected_quants = wizard.quants_lines.filtered(
|
||||
'selected').mapped('quant')
|
||||
self.assertEqual(
|
||||
sum(self.move.reserved_quant_ids.mapped('qty')),
|
||||
wizard.lines_qty)
|
||||
for quant in self.move.reserved_quant_ids:
|
||||
self.assertTrue(quant in selected_quants)
|
||||
|
||||
def test_quant_assign_wizard_after_availability_check(self):
|
||||
self.move.action_assign()
|
||||
|
||||
Reference in New Issue
Block a user