From 923691c69f5d834072ad89c5658be28b4495a654 Mon Sep 17 00:00:00 2001 From: Hai Lang Date: Sat, 10 Jul 2021 13:33:52 +0700 Subject: [PATCH] [IMP] sale_order_line_packaging_qty: increase coverage --- sale_order_line_packaging_qty/__manifest__.py | 2 +- .../test_sale_order_line_packaging_qty.py | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/sale_order_line_packaging_qty/__manifest__.py b/sale_order_line_packaging_qty/__manifest__.py index 6a06257aedf..76d65b91d01 100644 --- a/sale_order_line_packaging_qty/__manifest__.py +++ b/sale_order_line_packaging_qty/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Sale Order Line Packaging Quantity", "summary": "Define quantities according to product packaging on sale order lines", - "version": "14.0.0.1.0", + "version": "14.0.1.0.0", "development_status": "Alpha", "category": "Warehouse Management", "website": "https://github.com/OCA/sale-workflow", diff --git a/sale_order_line_packaging_qty/tests/test_sale_order_line_packaging_qty.py b/sale_order_line_packaging_qty/tests/test_sale_order_line_packaging_qty.py index d1edbe56c24..43030314b6f 100644 --- a/sale_order_line_packaging_qty/tests/test_sale_order_line_packaging_qty.py +++ b/sale_order_line_packaging_qty/tests/test_sale_order_line_packaging_qty.py @@ -39,10 +39,15 @@ def test_product_packaging_qty(self): order_line._onchange_product_packaging_qty() self.assertEqual(order_line.product_uom_qty, 15.0) + order_line.write({"product_uom_qty": 9.0}) + self.assertEqual(order_line.product_packaging_qty, 0.0) + order_line.write({"product_uom_qty": 15.0}) + dozen = self.env.ref("uom.product_uom_dozen") order_line.product_uom = dozen order_line._compute_product_packaging_qty() self.assertEqual(order_line.product_uom_qty, 180.0) + self.assertEqual(order_line.product_uom, self.product.uom_id) self.packaging.qty = 0 with self.assertRaises(UserError): @@ -67,3 +72,21 @@ def test_product_packaging_qty_wo_packaging(self): self.assertEqual(order_line.product_packaging_qty, 0.0) with self.assertRaises(UserError): order_line.write({"product_packaging_qty": 3.0}) + + def test_product_packaging_qty_from_external(self): + """The previous ones have product_uom_qty of 3, which is less than and + not divisible by packaging qty of 5. This test is to increase coverage + for the case that product_uom_qty of 15 is divisible by 5. + """ + order = self.env["sale.order"].create({"partner_id": self.partner.id}) + order_line = self.env["sale.order.line"].create( + { + "order_id": order.id, + "product_id": self.product.id, + "product_uom": self.product.uom_id.id, + "product_uom_qty": 15.0, + } + ) + order_line.write({"product_packaging": self.packaging}) + order_line._onchange_product_packaging() + self.assertEqual(order_line.product_packaging_qty, 3.0)