Bug create contract
This commit is contained in:
@@ -33,9 +33,11 @@ class ContractFactory:
|
||||
Purchase = pool.get('purchase.purchase')
|
||||
SaleLine = pool.get('sale.line')
|
||||
PurchaseLine = pool.get('purchase.line')
|
||||
Lot = pool.get('lot.lot')
|
||||
Date = pool.get('ir.date')
|
||||
|
||||
created = []
|
||||
lines_to_check = []
|
||||
sources = cls._get_sources(ct, type_)
|
||||
cls._validate_requested_quantity(contracts, sources, ct)
|
||||
base_contract = cls._get_base_contract(sources, ct, type_)
|
||||
@@ -104,9 +106,13 @@ class ContractFactory:
|
||||
|
||||
if ct.matched:
|
||||
cls._create_lot(line, c, source, type_)
|
||||
lines_to_check.append(line)
|
||||
if source.get('trade_line'):
|
||||
lines_to_check.append(source['trade_line'])
|
||||
|
||||
created.append(contract)
|
||||
|
||||
Lot.assert_lines_quantity_consistency(lines_to_check)
|
||||
return created
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
@@ -325,24 +331,26 @@ class ContractFactory:
|
||||
lqh.gross_quantity = round(lot.lot_quantity, 5)
|
||||
lot.lot_hist = [lqh]
|
||||
|
||||
lot.save()
|
||||
with Transaction().set_context(
|
||||
_purchase_trade_skip_quantity_consistency=True):
|
||||
lot.save()
|
||||
|
||||
vlot = source['lot']
|
||||
shipment_origin = source.get('shipment_origin')
|
||||
qt = source['quantity']
|
||||
vlot = source['lot']
|
||||
shipment_origin = source.get('shipment_origin')
|
||||
qt = source['quantity']
|
||||
|
||||
if type_ == 'Purchase':
|
||||
if not lot.updateVirtualPart(qt, shipment_origin, vlot):
|
||||
lot.createVirtualPart(qt, shipment_origin, vlot)
|
||||
if type_ == 'Purchase':
|
||||
if not lot.updateVirtualPart(qt, shipment_origin, vlot):
|
||||
lot.createVirtualPart(qt, shipment_origin, vlot)
|
||||
|
||||
# Decrease forecasted virtual part non matched
|
||||
lot.updateVirtualPart(-qt, shipment_origin, vlot, 'only sale')
|
||||
else:
|
||||
if not vlot.updateVirtualPart(qt, shipment_origin, lot):
|
||||
vlot.createVirtualPart(qt, shipment_origin, lot)
|
||||
# Decrease forecasted virtual part non matched
|
||||
lot.updateVirtualPart(-qt, shipment_origin, vlot, 'only sale')
|
||||
else:
|
||||
if not vlot.updateVirtualPart(qt, shipment_origin, lot):
|
||||
vlot.createVirtualPart(qt, shipment_origin, lot)
|
||||
|
||||
# Decrease forecasted virtual part non matched
|
||||
vlot.updateVirtualPart(-qt, shipment_origin, None)
|
||||
# Decrease forecasted virtual part non matched
|
||||
vlot.updateVirtualPart(-qt, shipment_origin, None)
|
||||
|
||||
@staticmethod
|
||||
def _get_shipment_origin(ct):
|
||||
|
||||
Reference in New Issue
Block a user