Skip to content

Commit

Permalink
[FIX] sale_stock: update SO line with import
Browse files Browse the repository at this point in the history
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#130870

X-original-commit: 87f62c9
Signed-off-by: Tiffany Chang (tic) <tic@odoo.com>
Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
  • Loading branch information
amoyaux committed Aug 22, 2023
1 parent e7128d6 commit 88a9074
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 12 deletions.
26 changes: 26 additions & 0 deletions addons/sale_stock/tests/test_sale_stock.py
Original file line number Diff line number Diff line change
Expand Up @@ -1184,6 +1184,32 @@ def test_18_deliver_more_and_multi_uom(self):
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()
Expand Down
9 changes: 0 additions & 9 deletions addons/stock/i18n/stock.pot
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions addons/stock/models/stock_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,6 @@ def create_move(move_line):
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']
Expand Down

0 comments on commit 88a9074

Please sign in to comment.