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