Skip to content

Commit

Permalink
[IMP] sale_order_line_packaging_qty: increase coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
hailangvn committed Jul 13, 2021
1 parent 4a5c284 commit 923691c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sale_order_line_packaging_qty/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)

0 comments on commit 923691c

Please sign in to comment.