diff --git a/modules/automation/cron.py b/modules/automation/cron.py index 939edc1..079da63 100644 --- a/modules/automation/cron.py +++ b/modules/automation/cron.py @@ -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): diff --git a/modules/purchase_trade/lot.py b/modules/purchase_trade/lot.py index c347ada..4b2d474 100755 --- a/modules/purchase_trade/lot.py +++ b/modules/purchase_trade/lot.py @@ -911,10 +911,9 @@ class Lot(metaclass=PoolMeta): virtual_lots = [l for l in lots if l.lot_type == 'virtual'] 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: + theorical = line.quantity_theorical if hasattr(line, 'quantity_theorical') else line.quantity + virtual_qty = round(theorical - total_physic, 5) + if virtual_lots: vlot = virtual_lots[0] lh = vlot.lot_hist[0] lh.quantity = virtual_qty @@ -1196,8 +1195,7 @@ 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: + for lot in lots: if len(lots) > 1: if lot.lot_type == 'physic': qt += lot.get_current_quantity_converted()