diff --git a/addons/sale_stock/tests/test_sale_stock.py b/addons/sale_stock/tests/test_sale_stock.py index 97c2f0e4e8d..e8b424c96e6 100644 --- a/addons/sale_stock/tests/test_sale_stock.py +++ b/addons/sale_stock/tests/test_sale_stock.py @@ -1184,6 +1184,32 @@ class TestSaleStock(TestSaleCommon, ValuationReconciliationTestCommon): self.assertEqual(so.order_line[1].qty_delivered, 1) self.assertEqual(so.order_line[1].product_uom.id, uom_km_id) + def test_19_deliver_update_so_line_qty(self): + """ + Creates a sale order, then validates the delivery + modifying the sale order lines qty via import and ensures + a new delivery is created. + """ + self.product_a.type = 'product' + self.env['stock.quant']._update_available_quantity( + self.product_a, self.company_data['default_warehouse'].lot_stock_id, 10) + + # Create sale order + sale_order = self._get_new_sale_order() + sale_order.action_confirm() + + # Validate delivery + picking = sale_order.picking_ids + picking.move_ids.write({'quantity_done': 10}) + picking.button_validate() + + # Update the line and check a new delivery is created + with Form(sale_order.with_context(import_file=True)) as so_form: + with so_form.order_line.edit(0) as line: + line.product_uom_qty = 777 + + self.assertEqual(len(sale_order.picking_ids), 2) + def test_multiple_returns(self): # Creates a sale order for 10 products. sale_order = self._get_new_sale_order() diff --git a/addons/stock/i18n/stock.pot b/addons/stock/i18n/stock.pot index 50826bda4e0..2e243127aef 100644 --- a/addons/stock/i18n/stock.pot +++ b/addons/stock/i18n/stock.pot @@ -3820,15 +3820,6 @@ msgstr "" msgid "Is quantity done editable" msgstr "" -#. module: stock -#. odoo-python -#: code:addons/stock/models/stock_move_line.py:0 -#, python-format -msgid "" -"It is not allowed to import reserved quantity, you have to use the quantity " -"directly." -msgstr "" - #. module: stock #. odoo-python #: code:addons/stock/models/stock_quant.py:0 diff --git a/addons/stock/models/stock_move_line.py b/addons/stock/models/stock_move_line.py index 8985cd50264..c62d798451d 100644 --- a/addons/stock/models/stock_move_line.py +++ b/addons/stock/models/stock_move_line.py @@ -362,9 +362,6 @@ class StockMoveLine(models.Model): move.with_context(avoid_putaway_rules=True).product_uom_qty = move.quantity_done for ml, vals in zip(mls, vals_list): - if self.env.context.get('import_file') and ml.reserved_uom_qty and not ml.move_id._should_bypass_reservation(): - raise UserError(_("It is not allowed to import reserved quantity, you have to use the quantity directly.")) - if ml.state == 'done': if ml.product_id.type == 'product' and not self.env.context.get('bypass_reservation_update'): Quant = self.env['stock.quant']