Faircot cron

This commit is contained in:
2026-07-20 09:30:31 +02:00
parent d6fa273d11
commit a70c2c4853
2 changed files with 26 additions and 7 deletions

View File

@@ -223,6 +223,13 @@ class AutomationCron(ModelSQL, ModelView):
value = str(value or '').strip()
if value.lower() in {'none', 'null'}:
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
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,
controller):
changed = False
columns = []
values = []
booking_bl_number = normalize_bl_number(bl_number)
shipment_bl_number = normalize_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.bl_number, booking_bl_number)
shipment.bl_number = booking_bl_number
columns.append('bl_number')
values.append(booking_bl_number)
changed = True
if bl_date and shipment.bl_date != bl_date:
logger.info(
@@ -251,6 +262,8 @@ class AutomationCron(ModelSQL, ModelView):
shipment.id, shipment.reference,
shipment.bl_date, bl_date)
shipment.bl_date = bl_date
columns.append('bl_date')
values.append(bl_date)
changed = True
if etd_date and shipment.etd != etd_date:
logger.info(
@@ -259,12 +272,20 @@ class AutomationCron(ModelSQL, ModelView):
shipment.id, shipment.reference,
shipment.etd, etd_date)
shipment.etd = etd_date
columns.append('etd')
values.append(etd_date)
changed = True
if controller and shipment.controller_target != controller:
shipment.controller_target = controller
columns.append('controller_target')
values.append(controller)
changed = True
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
for i, row in enumerate(rows2, 1):

View File

@@ -913,7 +913,6 @@ class Lot(metaclass=PoolMeta):
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
virtual_qty = round(theorical - total_physic, 5)
logger.info("RECOMPUTE_VIRTUAL_LOT:%s",virtual_qty)
if virtual_lots:
vlot = virtual_lots[0]
lh = vlot.lot_hist[0]
@@ -1196,7 +1195,6 @@ class Lot(metaclass=PoolMeta):
line = SL(line_id)
qt = Decimal(0)
lots = list(line.lots or [])
logger.info("DELETE_RECALC:%s",lots)
for lot in lots:
if len(lots) > 1:
if lot.lot_type == 'physic':