Bug Add physical lot
This commit is contained in:
@@ -1277,24 +1277,31 @@ class LotQt(
|
||||
Purchase = Pool().get('purchase.purchase')
|
||||
LotQt = Pool().get('lot.qt')
|
||||
Lot = Pool().get('lot.lot')
|
||||
Uom = Pool().get('product.uom')
|
||||
purchase = lqt.lot_p.line.purchase
|
||||
lots = []
|
||||
tot_qt = 0
|
||||
for l in vlots:
|
||||
tot_qt += Decimal(str(Uom.compute_qty(
|
||||
l.lot_unit_line, float(l.lot_quantity or 0),
|
||||
lqt.lot_p.line.unit)))
|
||||
tot_qt = round(tot_qt, 5)
|
||||
with Transaction().set_context(
|
||||
_purchase_trade_skip_quantity_consistency=True):
|
||||
for l in vlots:
|
||||
lot,qt = lqt.add_physical_lot(l)
|
||||
lots.append(lot)
|
||||
tot_qt += qt
|
||||
|
||||
#create move for lots
|
||||
Purchase._process_shipment([purchase],lots)
|
||||
|
||||
#update LotQt
|
||||
lqt.lot_quantity -= round(tot_qt,5)
|
||||
# Consume the forecast first. Physical lot saves recompute the
|
||||
# virtual lot, so the matching lot.qt must already carry the
|
||||
# target open quantity during the rest of the transaction.
|
||||
lqt.lot_quantity -= tot_qt
|
||||
if lqt.lot_quantity < 0:
|
||||
lqt.lot_quantity = 0
|
||||
LotQt.save([lqt])
|
||||
|
||||
for l in vlots:
|
||||
lot,qt = lqt.add_physical_lot(l)
|
||||
lots.append(lot)
|
||||
|
||||
#create move for lots
|
||||
Purchase._process_shipment([purchase],lots)
|
||||
affected_lines = []
|
||||
if lqt.lot_p and lqt.lot_p.line:
|
||||
affected_lines.append(lqt.lot_p.line)
|
||||
|
||||
Reference in New Issue
Block a user