[FIX] stock: _check_backorder

Check backorder is divided in 3 blocks:
1) quantities on move lines linked to a move
2) quantities on move lines without moves nor products but with a
package
3) quantities on move lines without moves but with a product

1) added quantities in the move's uom, 2) added quantitis in the product
uom, 3) doesn't seem to be used (and shouldn't be). Clarify all of that.

task-2239964

closes odoo/odoo#49790

Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
This commit is contained in:
Simon Lejeune
2020-05-25 09:50:11 +00:00
parent 38b2c9e8f8
commit fadaf8b748
2 changed files with 3 additions and 4 deletions
+3 -2
View File
@@ -964,8 +964,9 @@ class Picking(models.Model):
for move in picking.mapped('move_lines'):
quantity_todo.setdefault(move.product_id.id, 0)
quantity_done.setdefault(move.product_id.id, 0)
quantity_todo[move.product_id.id] += move.product_uom_qty
quantity_done[move.product_id.id] += move.quantity_done
quantity_todo[move.product_id.id] += move.product_uom._compute_quantity(move.product_uom_qty, move.product_id.uom_id, rounding_method='HALF-UP')
quantity_done[move.product_id.id] += move.product_uom._compute_quantity(move.quantity_done, move.product_id.uom_id, rounding_method='HALF-UP')
# FIXME: the next block doesn't seem nor should be used.
for ops in picking.mapped('move_line_ids').filtered(lambda x: x.package_id and not x.product_id and not x.move_id):
for quant in ops.package_id.quant_ids:
quantity_done.setdefault(quant.product_id.id, 0)
-2
View File
@@ -1037,8 +1037,6 @@ class TestStockFlow(TestStockCommon):
res_dict = bo_out_3.button_validate()
wizard = Form(self.env[(res_dict.get('res_model'))].with_context(res_dict['context'])).save()
res_dict_for_back_order = wizard.process()
backorder_wizard = self.env[(res_dict_for_back_order.get('res_model'))].browse(res_dict_for_back_order.get('res_id')).with_context(res_dict_for_back_order['context'])
backorder_wizard.process()
quants = self.StockQuantObj.search([('product_id', '=', productKG.id), ('location_id', '=', self.stock_location)])
total_qty = [quant.quantity for quant in quants]
self.assertEqual(sum(total_qty), 999.9980, 'Expecting 999.9980 kg , got %.4f kg on location stock!' % (sum(total_qty)))