[FIX] stock: Usererror during PO import
Usecase to reproduce: - Create and validate a PO + receipt - Import a file containing a different PO line quantity Expected behavior: The PO line is modified and the receipt has the a new move Current behavior: UserError asking to modify the quantity done of stock.move.line instead reserved quantity. Following commit 76ad7b7dedab3c504c9231359b07d01505d0cc0e The purpose is to block import with reserved quantity It happens because the PO line import trigger the creation of a new stock.move and reserve it (create the stock.move.line). However since it's created by the system the data are correct. There is no issue in multiple step since the internal step requires the move_orig_ids and thus the product_uom_qty is empty To fix it: - Relax the constraint to only consider sml having an impact on quant opw-3336131 closes odoo/odoo#128157 X-original-commit: a755db18981f23f031fdf21b58b309e3210df262 Signed-off-by: William Henrotin (whe) <whe@odoo.com>
This commit is contained in:
committed by
William Henrotin
parent
a4a94fa133
commit
0be5070983
@@ -302,8 +302,6 @@ class StockMoveLine(models.Model):
|
||||
vals['company_id'] = self.env['stock.picking'].browse(vals['picking_id']).company_id.id
|
||||
if vals.get('quant_id'):
|
||||
vals.update(self._copy_quant_info(vals))
|
||||
if self.env.context.get('import_file') and vals.get('reserved_uom_qty'):
|
||||
raise UserError(_("It is not allowed to import reserved quantity, you have to use the quantity directly."))
|
||||
|
||||
mls = super().create(vals_list)
|
||||
|
||||
@@ -315,6 +313,8 @@ class StockMoveLine(models.Model):
|
||||
# If this picking is already done we should generate an
|
||||
# associated done move.
|
||||
for move_line in mls:
|
||||
if self.env.context.get('import_file') and move_line.reserved_uom_qty and not move_line._should_bypass_reservation(move_line.location_id):
|
||||
raise UserError(_("It is not allowed to import reserved quantity, you have to use the quantity directly."))
|
||||
if move_line.move_id or not move_line.picking_id:
|
||||
continue
|
||||
if move_line.picking_id.state != 'done':
|
||||
|
||||
Reference in New Issue
Block a user