FG Scan form validation improvements with warehouse module updates

- Fixed 3 JavaScript syntax errors in fg_scan.html (lines 951, 840-950, 1175-1215)
- Restored form field validation with proper null safety checks
- Re-enabled auto-advance between form fields
- Re-enabled CP code auto-complete with hyphen detection
- Updated validation error messages with clear format specifications and examples
- Added autocomplete='off' to all input fields
- Removed auto-prefix correction feature
- Updated warehouse routes and modules for box assignment workflow
- Added/improved database initialization scripts
- Updated requirements.txt dependencies

Format specifications implemented:
- Operator Code: OP + 2 digits (example: OP01, OP99)
- CP Code: CP + 8 digits + hyphen + 4 digits (example: CP00000000-0001)
- OC1/OC2 Codes: OC + 2 digits (example: OC01, OC99)
- Defect Code: 3 digits only
This commit is contained in:
Quality App Developer
2026-01-30 10:50:06 +02:00
parent ac24e20fe1
commit b15cc93b9d
48 changed files with 16452 additions and 607 deletions

View File

@@ -4,7 +4,9 @@ Warehouse Module Routes
from flask import Blueprint, render_template, session, redirect, url_for, request, flash, jsonify
from app.modules.warehouse.warehouse import (
get_all_locations, add_location, update_location, delete_location,
delete_multiple_locations, get_location_by_id
delete_multiple_locations, get_location_by_id,
search_box_by_number, search_location_with_boxes,
assign_box_to_location, move_box_to_new_location
)
import logging
@@ -123,3 +125,93 @@ def test_barcode():
return redirect(url_for('main.login'))
return render_template('modules/warehouse/test_barcode.html')
# ============================================================================
# API Routes for Set Boxes Locations Feature
# ============================================================================
@warehouse_bp.route('/api/search-box', methods=['POST'], endpoint='api_search_box')
def api_search_box():
"""Search for a box by number"""
if 'user_id' not in session:
return jsonify({'success': False, 'error': 'Unauthorized'}), 401
data = request.get_json()
box_number = data.get('box_number', '').strip()
if not box_number:
return jsonify({'success': False, 'error': 'Box number is required'}), 400
success, box_data, status_code = search_box_by_number(box_number)
if success:
return jsonify({'success': True, 'box': box_data}), 200
else:
return jsonify({'success': False, 'error': f'Box "{box_number}" not found'}), status_code
@warehouse_bp.route('/api/search-location', methods=['POST'], endpoint='api_search_location')
def api_search_location():
"""Search for a location and get all boxes in it"""
if 'user_id' not in session:
return jsonify({'success': False, 'error': 'Unauthorized'}), 401
data = request.get_json()
location_code = data.get('location_code', '').strip()
if not location_code:
return jsonify({'success': False, 'error': 'Location code is required'}), 400
success, response_data, status_code = search_location_with_boxes(location_code)
if success:
return jsonify({'success': True, **response_data}), 200
else:
return jsonify({'success': False, 'error': response_data.get('error', 'Not found')}), status_code
@warehouse_bp.route('/api/assign-box-to-location', methods=['POST'], endpoint='api_assign_box_to_location')
def api_assign_box_to_location():
"""Assign a box to a location"""
if 'user_id' not in session:
return jsonify({'success': False, 'error': 'Unauthorized'}), 401
data = request.get_json()
box_id = data.get('box_id')
location_code = data.get('location_code', '').strip()
if not box_id or not location_code:
return jsonify({'success': False, 'error': 'Box ID and location code are required'}), 400
success, message, status_code = assign_box_to_location(box_id, location_code)
return jsonify({'success': success, 'message': message}), status_code
@warehouse_bp.route('/api/move-box-to-location', methods=['POST'], endpoint='api_move_box_to_location')
def api_move_box_to_location():
"""Move a box to a new location"""
if 'user_id' not in session:
return jsonify({'success': False, 'error': 'Unauthorized'}), 401
data = request.get_json()
box_id = data.get('box_id')
new_location_code = data.get('new_location_code', '').strip()
if not box_id or not new_location_code:
return jsonify({'success': False, 'error': 'Box ID and new location code are required'}), 400
success, message, status_code = move_box_to_new_location(box_id, new_location_code)
return jsonify({'success': success, 'message': message}), status_code
@warehouse_bp.route('/api/get-locations', methods=['GET'], endpoint='api_get_locations')
def api_get_locations():
"""Get all warehouse locations for dropdown"""
if 'user_id' not in session:
return jsonify({'success': False, 'error': 'Unauthorized'}), 401
locations = get_all_locations()
return jsonify({'success': True, 'locations': locations}), 200