[FIX] sale_stock: update SO line with import
Creates a sale order, then validates the delivery. Modify the sale order lines qty via import. We expect a new delivery instead we have a UserError The purpose of the userError is to avoid editing reserved quantity directly in the picking. But in SO/PO case it's handle by the system and quantities are correctly reserved so the UserError should not happens. Remove the basic constraint on stock since it should not be an issue anymore opw-3336131 closes odoo/odoo#130870 X-original-commit: 87f62c90e703049bde8676663851a98e3b19f9db Signed-off-by: Tiffany Chang (tic) <tic@odoo.com> Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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']
|
||||
|
||||
Reference in New Issue
Block a user