[FIX] stock: traceback during PO import
Following #127245 It happens because `_should_bypass_reservation` has been removed in 15.0 and only exist on the `stock.move` object and not the `stock.move.line` anymore opw-3336131 closes odoo/odoo#129076 X-original-commit: 7e917e8713e246811531f9d7c90395242e544057 Signed-off-by: William Henrotin (whe) <whe@odoo.com>
This commit is contained in:
committed by
William Henrotin
parent
bade33c935
commit
ed54c39ef7
@@ -630,3 +630,12 @@ class TestPurchaseOrder(ValuationReconciliationTestCommon):
|
||||
wizard = self.env['stock.inventory.adjustment.name'].create({'quant_ids': quant})
|
||||
wizard.action_apply()
|
||||
self.assertEqual(quant.quantity, 5)
|
||||
|
||||
def test_po_edit_after_receive(self):
|
||||
self.po = self.env['purchase.order'].create(self.po_vals)
|
||||
self.po.button_confirm()
|
||||
self.po.picking_ids.move_ids.quantity_done = 5
|
||||
self.po.picking_ids.button_validate()
|
||||
self.assertEqual(self.po.picking_ids.move_ids.mapped('product_uom_qty'), [5.0, 5.0])
|
||||
self.po.with_context(import_file=True).order_line[0].product_qty = 10
|
||||
self.assertEqual(self.po.picking_ids.move_ids.mapped('product_uom_qty'), [5.0, 5.0, 5.0])
|
||||
|
||||
@@ -313,8 +313,6 @@ 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':
|
||||
@@ -364,6 +362,9 @@ 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