[FIX] rma: compute out_shipment_count correctly. Add test cases

This commit is contained in:
Jordi Ballester
2022-02-07 09:16:32 +01:00
committed by Lois Rilo
parent c73d2a0710
commit 741ac0052b
2 changed files with 83 additions and 34 deletions

View File

@@ -291,7 +291,8 @@ class TestRma(common.SavepointCase):
moves = picking.move_lines
self.assertEquals(len(moves), 3, "Incorrect number of moves created")
lines = self.rma_customer_id.rma_line_ids
self.assertEquals(
lines.refresh()
self.assertEqual(
list(set(lines.mapped("qty_received"))), [0], "Wrong qty received"
)
self.assertEquals(
@@ -303,6 +304,18 @@ class TestRma(common.SavepointCase):
self.assertEquals(
list(set(lines.mapped("qty_delivered"))), [0], "Wrong qty delivered"
)
self.assertEqual(
sum(lines.mapped("in_shipment_count")), 3, "Incorrect In Shipment Count"
)
self.assertEqual(
sum(lines.mapped("out_shipment_count")), 0, "Incorrect Out Shipment Count"
)
self.assertEqual(
self.rma_customer_id.in_shipment_count, 1, "Incorrect In Shipment Count"
)
self.assertEqual(
self.rma_customer_id.out_shipment_count, 0, "Incorrect Out Shipment Count"
)
# product specific
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_1).qty_to_receive,
@@ -334,7 +347,6 @@ class TestRma(common.SavepointCase):
2,
"Wrong qty incoming",
)
picking.action_assign()
for mv in picking.move_lines:
mv.quantity_done = mv.product_uom_qty
@@ -399,7 +411,8 @@ class TestRma(common.SavepointCase):
moves = picking.move_lines
self.assertEquals(len(moves), 3, "Incorrect number of moves created")
lines = self.rma_customer_id.rma_line_ids
self.assertEquals(
lines.refresh()
self.assertEqual(
list(set(lines.mapped("qty_to_receive"))), [0], "Wrong qty to_receive"
)
self.assertEquals(
@@ -408,7 +421,18 @@ class TestRma(common.SavepointCase):
self.assertEquals(
list(set(lines.mapped("qty_delivered"))), [0], "Wrong qty delivered"
)
self.assertEqual(
sum(lines.mapped("in_shipment_count")), 3, "Incorrect In Shipment Count"
)
self.assertEqual(
sum(lines.mapped("out_shipment_count")), 3, "Incorrect Out Shipment Count",
)
self.assertEqual(
self.rma_customer_id.in_shipment_count, 1, "Incorrect In Shipment Count"
)
self.assertEqual(
self.rma_customer_id.out_shipment_count, 1, "Incorrect Out Shipment Count"
)
# product specific
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_1).qty_to_deliver,
@@ -440,7 +464,6 @@ class TestRma(common.SavepointCase):
2,
"Wrong qty outgoing",
)
picking.action_assign()
for mv in picking.move_lines:
mv.quantity_done = mv.product_uom_qty
@@ -455,7 +478,6 @@ class TestRma(common.SavepointCase):
self.assertEquals(
list(set(lines.mapped("qty_outgoing"))), [0], "Wrong qty_outgoing"
)
# product specific
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_1).qty_received,
@@ -487,7 +509,6 @@ class TestRma(common.SavepointCase):
2,
"Wrong qty_delivered",
)
self.line.action_rma_done()
self.assertEquals(self.line.state, "done", "Wrong State")
self.rma_customer_id.action_view_in_shipments()
@@ -512,11 +533,25 @@ class TestRma(common.SavepointCase):
).create({})
wizard._create_picking()
res = self.rma_droship_id.rma_line_ids.action_view_in_shipments()
self.assertTrue("res_id" in res, "Incorrect number of pickings" "created")
self.assertTrue("res_id" in res, "Incorrect number of pickings created")
picking = self.env["stock.picking"].browse(res["res_id"])
self.assertEquals(len(picking), 1, "Incorrect number of pickings created")
moves = picking.move_lines
self.assertEquals(len(moves), 3, "Incorrect number of moves created")
self.assertEqual(len(moves), 3, "Incorrect number of moves created")
lines = self.rma_droship_id.rma_line_ids
lines.refresh()
self.assertEqual(
sum(lines.mapped("in_shipment_count")), 3, "Incorrect In Shipment Count"
)
self.assertEqual(
sum(lines.mapped("out_shipment_count")), 0, "Incorrect Out Shipment Count"
)
self.assertEqual(
self.rma_droship_id.in_shipment_count, 1, "Incorrect In Shipment Count"
)
self.assertEqual(
self.rma_droship_id.out_shipment_count, 0, "Incorrect Out Shipment Count"
)
wizard = self.make_supplier_rma.with_context(
{
"active_ids": self.rma_droship_id.rma_line_ids.ids,
@@ -524,19 +559,16 @@ class TestRma(common.SavepointCase):
"active_id": 1,
}
).create({})
res = wizard.make_supplier_rma()
supplier_rma = self.rma.browse(res["res_id"])
lines = supplier_rma.rma_line_ids
self.assertEquals(
wizard.make_supplier_rma()
lines = self.rma_droship_id.rma_line_ids.mapped("supplier_rma_line_ids")
lines.refresh()
self.assertEqual(
list(set(lines.mapped("qty_received"))), [0], "Wrong qty_received"
)
self.assertEquals(
list(set(lines.mapped("qty_outgoing"))), [0], "Wrong qty_outgoing"
)
self.assertEquals(
list(set(lines.mapped("qty_delivered"))), [0], "qty_delivered"
)
self.assertEqual(list(set(lines.mapped("qty_delivered"))), [0], "qty_delivered")
# product specific
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_1).qty_to_deliver,
@@ -553,8 +585,8 @@ class TestRma(common.SavepointCase):
2,
"Wrong qty_to_deliver",
)
lines = self.rma_droship_id.rma_line_ids
lines.refresh()
self._check_equal_quantity(
lines.filtered(
lambda l: l.product_id == self.product_1
@@ -585,8 +617,7 @@ class TestRma(common.SavepointCase):
for line in self.rma_droship_id.rma_line_ids:
line.action_rma_done()
self.assertEquals(line.mapped("state"), ["done"], "Wrong State")
self.assertEqual(line.mapped("state"), ["done"], "Wrong State")
# Supplier RMA
def test_04_supplier_rma(self):
@@ -610,13 +641,23 @@ class TestRma(common.SavepointCase):
self.assertEquals(len(moves), 3, "Incorrect number of moves created")
lines = self.rma_supplier_id.rma_line_ids
self.assertEquals(
lines.refresh()
self.assertEqual(
list(set(lines.mapped("qty_received"))), [0], "Wrong qty_received"
)
self.assertEquals(
list(set(lines.mapped("qty_delivered"))), [0], "qty_delivered"
self.assertEqual(list(set(lines.mapped("qty_delivered"))), [0], "qty_delivered")
self.assertEqual(
sum(lines.mapped("in_shipment_count")), 0, "Incorrect In Shipment Count"
)
self.assertEqual(
sum(lines.mapped("out_shipment_count")), 3, "Incorrect Out Shipment Count"
)
self.assertEqual(
self.rma_supplier_id.in_shipment_count, 0, "Incorrect In Shipment Count"
)
self.assertEqual(
self.rma_supplier_id.out_shipment_count, 1, "Incorrect Out Shipment Count"
)
# product specific
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_1).qty_to_receive,
@@ -655,8 +696,7 @@ class TestRma(common.SavepointCase):
for mv in picking.move_lines:
mv.quantity_done = mv.product_uom_qty
picking.action_done()
self.assertEquals(
self.assertEqual(
list(set(lines.mapped("qty_incoming"))), [0], "Wrong qty_incoming"
)
self.assertEquals(
@@ -665,8 +705,7 @@ class TestRma(common.SavepointCase):
self.assertEquals(
list(set(lines.mapped("qty_received"))), [0], "Wrong qty_received"
)
self.assertEquals(list(set(lines.mapped("qty_outgoing"))), [0], "qty_outgoing")
self.assertEqual(list(set(lines.mapped("qty_outgoing"))), [0], "qty_outgoing")
# product specific
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_1).qty_delivered,
@@ -703,7 +742,6 @@ class TestRma(common.SavepointCase):
0,
"Wrong qty_received",
)
wizard = self.rma_make_picking.with_context(
{
"active_id": 1,
@@ -722,10 +760,22 @@ class TestRma(common.SavepointCase):
self.assertEquals(len(moves), 3, "Incorrect number of moves created")
lines = self.rma_supplier_id.rma_line_ids
self.assertEquals(
lines.refresh()
self.assertEqual(
list(set(lines.mapped("qty_to_deliver"))), [0], "qty_to_deliver"
)
self.assertEqual(
sum(lines.mapped("in_shipment_count")), 3, "Incorrect In Shipment Count"
)
self.assertEqual(
sum(lines.mapped("out_shipment_count")), 3, "Incorrect Out Shipment Count"
)
self.assertEqual(
self.rma_supplier_id.in_shipment_count, 1, "Incorrect In Shipment Count"
)
self.assertEqual(
self.rma_supplier_id.out_shipment_count, 1, "Incorrect Out Shipment Count"
)
# product specific
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_1).qty_to_receive,
@@ -742,7 +792,6 @@ class TestRma(common.SavepointCase):
2,
"Wrong qty_to_receive",
)
picking_in.action_confirm()
picking_in.action_assign()
for mv in picking_in.move_line_ids:
@@ -791,4 +840,4 @@ class TestRma(common.SavepointCase):
)
for line in self.rma_supplier_id.rma_line_ids:
line.action_rma_done()
self.assertEquals(line.mapped("state"), ["done"], "Wrong State")
self.assertEqual(line.mapped("state"), ["done"], "Wrong State")