Faircot cron
This commit is contained in:
@@ -223,6 +223,13 @@ class AutomationCron(ModelSQL, ModelView):
|
|||||||
value = str(value or '').strip()
|
value = str(value or '').strip()
|
||||||
if value.lower() in {'none', 'null'}:
|
if value.lower() in {'none', 'null'}:
|
||||||
return ''
|
return ''
|
||||||
|
if value.upper() in {
|
||||||
|
'MULTIPLE BL NUMBERS FOUND',
|
||||||
|
'MULTIPLE B/L NUMBERS FOUND',
|
||||||
|
'NO BL NUMBER FOUND',
|
||||||
|
'NO B/L NUMBER FOUND',
|
||||||
|
}:
|
||||||
|
return ''
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def normalize_booking_number(value):
|
def normalize_booking_number(value):
|
||||||
@@ -234,6 +241,8 @@ class AutomationCron(ModelSQL, ModelView):
|
|||||||
def sync_shipment_from_booking(shipment, bl_number, bl_date, etd_date,
|
def sync_shipment_from_booking(shipment, bl_number, bl_date, etd_date,
|
||||||
controller):
|
controller):
|
||||||
changed = False
|
changed = False
|
||||||
|
columns = []
|
||||||
|
values = []
|
||||||
booking_bl_number = normalize_bl_number(bl_number)
|
booking_bl_number = normalize_bl_number(bl_number)
|
||||||
shipment_bl_number = normalize_bl_number(shipment.bl_number)
|
shipment_bl_number = normalize_bl_number(shipment.bl_number)
|
||||||
if booking_bl_number and booking_bl_number != shipment_bl_number:
|
if booking_bl_number and booking_bl_number != shipment_bl_number:
|
||||||
@@ -243,6 +252,8 @@ class AutomationCron(ModelSQL, ModelView):
|
|||||||
shipment.id, shipment.reference,
|
shipment.id, shipment.reference,
|
||||||
shipment.bl_number, booking_bl_number)
|
shipment.bl_number, booking_bl_number)
|
||||||
shipment.bl_number = booking_bl_number
|
shipment.bl_number = booking_bl_number
|
||||||
|
columns.append('bl_number')
|
||||||
|
values.append(booking_bl_number)
|
||||||
changed = True
|
changed = True
|
||||||
if bl_date and shipment.bl_date != bl_date:
|
if bl_date and shipment.bl_date != bl_date:
|
||||||
logger.info(
|
logger.info(
|
||||||
@@ -251,6 +262,8 @@ class AutomationCron(ModelSQL, ModelView):
|
|||||||
shipment.id, shipment.reference,
|
shipment.id, shipment.reference,
|
||||||
shipment.bl_date, bl_date)
|
shipment.bl_date, bl_date)
|
||||||
shipment.bl_date = bl_date
|
shipment.bl_date = bl_date
|
||||||
|
columns.append('bl_date')
|
||||||
|
values.append(bl_date)
|
||||||
changed = True
|
changed = True
|
||||||
if etd_date and shipment.etd != etd_date:
|
if etd_date and shipment.etd != etd_date:
|
||||||
logger.info(
|
logger.info(
|
||||||
@@ -259,12 +272,20 @@ class AutomationCron(ModelSQL, ModelView):
|
|||||||
shipment.id, shipment.reference,
|
shipment.id, shipment.reference,
|
||||||
shipment.etd, etd_date)
|
shipment.etd, etd_date)
|
||||||
shipment.etd = etd_date
|
shipment.etd = etd_date
|
||||||
|
columns.append('etd')
|
||||||
|
values.append(etd_date)
|
||||||
changed = True
|
changed = True
|
||||||
if controller and shipment.controller_target != controller:
|
if controller and shipment.controller_target != controller:
|
||||||
shipment.controller_target = controller
|
shipment.controller_target = controller
|
||||||
|
columns.append('controller_target')
|
||||||
|
values.append(controller)
|
||||||
changed = True
|
changed = True
|
||||||
if changed:
|
if changed:
|
||||||
ShipmentIn.save([shipment])
|
table = ShipmentIn.__table__()
|
||||||
|
table_columns = [getattr(table, column) for column in columns]
|
||||||
|
cursor = Transaction().connection.cursor()
|
||||||
|
cursor.execute(*table.update(
|
||||||
|
table_columns, values, where=table.id == shipment.id))
|
||||||
return changed
|
return changed
|
||||||
|
|
||||||
for i, row in enumerate(rows2, 1):
|
for i, row in enumerate(rows2, 1):
|
||||||
|
|||||||
@@ -913,7 +913,6 @@ class Lot(metaclass=PoolMeta):
|
|||||||
total_physic = sum(l.get_current_quantity_converted() for l in physical_lots)
|
total_physic = sum(l.get_current_quantity_converted() for l in physical_lots)
|
||||||
theorical = line.quantity_theorical if hasattr(line, 'quantity_theorical') else line.quantity
|
theorical = line.quantity_theorical if hasattr(line, 'quantity_theorical') else line.quantity
|
||||||
virtual_qty = round(theorical - total_physic, 5)
|
virtual_qty = round(theorical - total_physic, 5)
|
||||||
logger.info("RECOMPUTE_VIRTUAL_LOT:%s",virtual_qty)
|
|
||||||
if virtual_lots:
|
if virtual_lots:
|
||||||
vlot = virtual_lots[0]
|
vlot = virtual_lots[0]
|
||||||
lh = vlot.lot_hist[0]
|
lh = vlot.lot_hist[0]
|
||||||
@@ -1196,7 +1195,6 @@ class Lot(metaclass=PoolMeta):
|
|||||||
line = SL(line_id)
|
line = SL(line_id)
|
||||||
qt = Decimal(0)
|
qt = Decimal(0)
|
||||||
lots = list(line.lots or [])
|
lots = list(line.lots or [])
|
||||||
logger.info("DELETE_RECALC:%s",lots)
|
|
||||||
for lot in lots:
|
for lot in lots:
|
||||||
if len(lots) > 1:
|
if len(lots) > 1:
|
||||||
if lot.lot_type == 'physic':
|
if lot.lot_type == 'physic':
|
||||||
|
|||||||
Reference in New Issue
Block a user