[FIX] stock: use precision_rounding instead of digits with float_is_zero
Steps to reproduce the bug:
- Create a storable product “P1”
- UoM: gram
- Create an internal picking with 0.01g of P1
- Validate the picking
- Create a return and try to validate it
Problem:
A UserError is triggered: “Please specify at least one non-zero quantity.”
When creating a return, we check if the quantity is not zero using the
“float_is_zero” function, but we mistakenly use rounding as
precision_digits.
opw-3862142"
closes odoo/odoo#162389
Signed-off-by: Quentin Wolfs (quwo) <quwo@odoo.com>
This commit is contained in:
@@ -178,8 +178,9 @@ class TestReturnPicking(TestStockCommon):
|
||||
|
||||
def test_return_wizard_with_partial_delivery(self):
|
||||
"""
|
||||
Create a picking for 10 units, deliver 6, and do not backorder the remaining 4.
|
||||
Then, attempt to return the quantity that was delivered. The return should be created with the correct quantity.
|
||||
Create a picking for 10 grams, deliver 0.01, and do not backorder the remaining quantity.
|
||||
Then, attempt to return the quantity that was delivered. The quantity should be properly verified
|
||||
to not be equal to 0 and the return should be created.
|
||||
"""
|
||||
delivery_picking = self.PickingObj.create({
|
||||
'picking_type_id': self.picking_type_out,
|
||||
@@ -188,14 +189,14 @@ class TestReturnPicking(TestStockCommon):
|
||||
})
|
||||
out_move = self.MoveObj.create({
|
||||
'name': "OUT move",
|
||||
'product_id':self.productA.id,
|
||||
'product_id': self.gB.id,
|
||||
'product_uom_qty': 10,
|
||||
'picking_id': delivery_picking.id,
|
||||
'location_id': self.stock_location,
|
||||
'location_dest_id': self.customer_location,
|
||||
})
|
||||
delivery_picking.action_confirm()
|
||||
out_move.quantity = 6
|
||||
out_move.quantity = 0.01
|
||||
# No backorder
|
||||
res_dict = delivery_picking.with_context(picking_ids_not_to_backorder=delivery_picking.id).button_validate()
|
||||
|
||||
@@ -206,4 +207,4 @@ class TestReturnPicking(TestStockCommon):
|
||||
.with_context(active_ids=delivery_picking.ids, active_id=delivery_picking.ids[0],
|
||||
active_model='stock.picking'))
|
||||
stock_return_picking = stock_return_picking_form.save()
|
||||
self.assertEqual(stock_return_picking.product_return_moves.quantity, 6)
|
||||
self.assertEqual(stock_return_picking.product_return_moves.quantity, 0.01)
|
||||
|
||||
@@ -142,7 +142,7 @@ class ReturnPicking(models.TransientModel):
|
||||
for return_line in self.product_return_moves:
|
||||
if not return_line.move_id:
|
||||
raise UserError(_("You have manually created product lines, please delete them to proceed."))
|
||||
if not float_is_zero(return_line.quantity, return_line.uom_id.rounding):
|
||||
if not float_is_zero(return_line.quantity, precision_rounding=return_line.uom_id.rounding):
|
||||
returned_lines += 1
|
||||
vals = self._prepare_move_default_values(return_line, new_picking)
|
||||
r = return_line.move_id.copy(vals)
|
||||
|
||||
Reference in New Issue
Block a user