summaryrefslogtreecommitdiff
path: root/addons/purchase_stock/tests/test_create_picking.py
diff options
context:
space:
mode:
Diffstat (limited to 'addons/purchase_stock/tests/test_create_picking.py')
-rw-r--r--addons/purchase_stock/tests/test_create_picking.py62
1 files changed, 62 insertions, 0 deletions
diff --git a/addons/purchase_stock/tests/test_create_picking.py b/addons/purchase_stock/tests/test_create_picking.py
index a727fea2371..de209d06319 100644
--- a/addons/purchase_stock/tests/test_create_picking.py
+++ b/addons/purchase_stock/tests/test_create_picking.py
@@ -315,6 +315,68 @@ class TestCreatePicking(common.TestProductCommon):
self.assertEqual(sum(customer_picking.move_lines.mapped('reserved_availability')), 100.0, 'The total quantity for the customer move should be available and reserved.')
+ def test_04_rounding(self):
+ """ We set the Unit(s) rounding to 1.0 and ensure buying 1.2 units in a PO is rounded to 1.0
+ at reception.
+ """
+ uom_unit = self.env.ref('uom.product_uom_unit')
+ uom_unit.rounding = 1.0
+
+ # buy a dozen
+ po = self.env['purchase.order'].create(self.po_vals)
+
+ po.order_line.product_qty = 1.2
+ po.button_confirm()
+
+ # the move should be 1.0 units
+ move1 = po.picking_ids.move_lines[0]
+ self.assertEqual(move1.product_uom_qty, 1.0)
+ self.assertEqual(move1.product_uom.id, uom_unit.id)
+ self.assertEqual(move1.product_qty, 1.0)
+
+ # edit the so line, buy 2.4 units, the move should now be 2.0 units
+ po.order_line.product_qty = 2.0
+ self.assertEqual(move1.product_uom_qty, 2.0)
+ self.assertEqual(move1.product_uom.id, uom_unit.id)
+ self.assertEqual(move1.product_qty, 2.0)
+
+ # deliver everything
+ move1.quantity_done = 2.0
+ po.picking_ids.button_validate()
+
+ # check the delivered quantity
+ self.assertEqual(po.order_line.qty_received, 2.0)
+
+ def test_05_uom_rounding(self):
+ """ We set the Unit(s) and Dozen(s) rounding to 1.0 and ensure buying 1.3 dozens in a PO is
+ rounded to 1.0 at reception.
+ """
+ uom_unit = self.env.ref('uom.product_uom_unit')
+ uom_dozen = self.env.ref('uom.product_uom_dozen')
+ uom_unit.rounding = 1.0
+ uom_dozen.rounding = 1.0
+
+ # buy 1.3 dozen
+ po = self.env['purchase.order'].create(self.po_vals)
+
+ po.order_line.product_qty = 1.3
+ po.order_line.product_uom = uom_dozen.id
+ po.button_confirm()
+
+ # the move should be 16.0 units
+ move1 = po.picking_ids.move_lines[0]
+ self.assertEqual(move1.product_uom_qty, 16.0)
+ self.assertEqual(move1.product_uom.id, uom_unit.id)
+ self.assertEqual(move1.product_qty, 16.0)
+
+ # force the propagation of the uom, buy 2.6 dozens, the move 2 should have 2 dozens
+ self.env['ir.config_parameter'].sudo().set_param('stock.propagate_uom', '1')
+ po.order_line.product_qty = 2.6
+ move2 = po.picking_ids.move_lines.filtered(lambda m: m.product_uom.id == uom_dozen.id)
+ self.assertEqual(move2.product_uom_qty, 2)
+ self.assertEqual(move2.product_uom.id, uom_dozen.id)
+ self.assertEqual(move2.product_qty, 24)
+
def create_delivery_order(self, propagate_date, propagate_date_minimum_delta):
stock_location = self.env['ir.model.data'].xmlid_to_object('stock.stock_location_stock')
customer_location = self.env['ir.model.data'].xmlid_to_object('stock.stock_location_customers')