[FIX] stock, delivery: put in pack and discard

rev[0] writes the qty done on the move lines directly in put_in_pack,
meaning hitting discard in the delivery wizard left the move lines with
a changed qty_done. We fix that by editing the quantities in
_put_in_pack in the stock module and getting the right move lines in the
delivery modules: meaning, get the normal or suggested ones (a fix
missed by rev[1]) then with quantities or 0 quantities.

[0] e03c1a836f
[1] f6d88a2e8d

closes odoo/odoo#37563

Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
This commit is contained in:
Simon Lejeune
2019-09-30 11:58:38 +00:00
parent 92d57bafd5
commit ad31097d8e
2 changed files with 16 additions and 3 deletions
@@ -43,10 +43,19 @@ class ChooseDeliveryPackage(models.TransientModel):
return {'warning': warning_mess}
def put_in_pack(self):
move_line_ids = self.picking_id.move_line_ids.filtered(lambda ml:
picking_move_lines = self.picking_id.move_line_ids
if not self.picking_id.picking_type_id.show_reserved:
picking_move_lines = self.picking_id.move_line_nosuggest_ids
move_line_ids = picking_move_lines.filtered(lambda ml:
float_compare(ml.qty_done, 0.0, precision_rounding=ml.product_uom_id.rounding) > 0
and not ml.result_package_id
)
if not move_line_ids:
move_line_ids = picking_move_lines.filtered(lambda ml: float_compare(ml.product_uom_qty, 0.0,
precision_rounding=ml.product_uom_id.rounding) > 0 and float_compare(ml.qty_done, 0.0,
precision_rounding=ml.product_uom_id.rounding) == 0)
delivery_package = self.picking_id._put_in_pack(move_line_ids)
# write shipping weight and product_packaging on 'stock_quant_package' if needed
if self.delivery_packaging_id:
+6 -2
View File
@@ -1143,6 +1143,12 @@ class Picking(models.Model):
for pick in self:
move_lines_to_pack = self.env['stock.move.line']
package = self.env['stock.quant.package'].create({})
precision_digits = self.env['decimal.precision'].precision_get('Product Unit of Measure')
if float_is_zero(move_line_ids[0].qty_done, precision_digits=precision_digits):
for line in move_line_ids:
line.qty_done = line.product_uom_qty
for ml in move_line_ids:
if float_compare(ml.qty_done, ml.product_uom_qty,
precision_rounding=ml.product_uom_id.rounding) >= 0:
@@ -1186,8 +1192,6 @@ class Picking(models.Model):
move_line_ids = picking_move_lines.filtered(lambda ml: float_compare(ml.product_uom_qty, 0.0,
precision_rounding=ml.product_uom_id.rounding) > 0 and float_compare(ml.qty_done, 0.0,
precision_rounding=ml.product_uom_id.rounding) == 0)
for line in move_line_ids:
line.qty_done = line.product_uom_qty
if move_line_ids:
res = self._pre_put_in_pack_hook(move_line_ids)
if not res: