fix: remove _oem_blocked() from catalog search/part + expose autoMatchCompat

- catalog_bp.py: /search and /part/<id> no longer blocked by CATALOG_OEM_ENABLED
  These endpoints query the master parts DB and enrich with local stock;
  they should work in both local and OEM modes.
- inventory.js: expose autoMatchCompat and removeCompat to window for
  onclick handlers in dynamically generated HTML.
- Regenerated inventory.min.js
This commit is contained in:
2026-05-01 00:30:10 +00:00
parent b27dd720aa
commit 91826487f9
3 changed files with 14 additions and 9 deletions

View File

@@ -337,9 +337,8 @@ def parts():
@catalog_bp.route('/part/<int:part_id>', methods=['GET'])
@require_auth('catalog.view')
def part_detail(part_id):
blocked = _oem_blocked()
if blocked:
return blocked
# Part detail is available in both local and OEM modes
# — it reads from the master parts DB and enriches with local stock.
def _do(master, tenant, branch_id):
result = catalog_service.get_part_detail(master, part_id, tenant, branch_id)
if not result:
@@ -351,9 +350,8 @@ def part_detail(part_id):
@catalog_bp.route('/search', methods=['GET'])
@require_auth('catalog.view')
def search():
blocked = _oem_blocked()
if blocked:
return blocked
# Search is available in both local and OEM modes
# — it reads from the master parts DB and enriches with local stock.
q = request.args.get('q', '').strip()
if not q or len(q) < 2:
return jsonify({'data': []})

View File

@@ -200,7 +200,11 @@
}
apiFetch(API + '/items', { method: 'POST', body: JSON.stringify(data) }).then(function (result) {
if (result && result.id) {
document.getElementById('createResult').innerHTML = '<span style="color:var(--color-success);">Creado ID ' + result.id + ' | Barcode: ' + result.barcode + '</span>';
var msg = 'Creado ID ' + result.id + ' | Barcode: ' + result.barcode;
if (result.vehicle_compatibilities_added > 0) {
msg += ' | ' + result.vehicle_compatibilities_added + ' vehiculo(s) asignado(s) por IA';
}
document.getElementById('createResult').innerHTML = '<span style="color:var(--color-success);">' + msg + '</span>';
loadItems(currentPage);
} else {
document.getElementById('createResult').innerHTML = '<span style="color:var(--color-error);">' + (result ? result.error || 'Error' : 'Error de red') + '</span>';
@@ -683,7 +687,8 @@
if (list.length > 0) {
html2 += '<table class="data-table"><thead><tr><th>Marca</th><th>Modelo</th><th>Ano</th><th>Motor</th><th>Origen</th><th></th></tr></thead><tbody>';
list.forEach(function(c) {
html2 += '<tr><td>' + esc(c.brand || '') + '</td><td>' + esc(c.model || '') + '</td><td>' + esc(c.year || '') + '</td><td>' + esc(c.engine || '') + '</td><td>' + esc(c.source || '') + '</td>';
var sourceLabel = c.source === 'qwen_ai' ? '<span style="background:var(--color-primary);color:#000;padding:2px 6px;border-radius:4px;font-size:10px;font-weight:600;">IA</span>' : (c.source === 'auto_match' ? '<span style="background:var(--color-success);color:#fff;padding:2px 6px;border-radius:4px;font-size:10px;font-weight:600;">TecDoc</span>' : esc(c.source || ''));
html2 += '<tr><td>' + esc(c.brand || '') + '</td><td>' + esc(c.model || '') + '</td><td>' + esc(c.year || '') + '</td><td>' + esc(c.engine || '') + '</td><td>' + sourceLabel + '</td>';
html2 += '<td><button class="btn btn--ghost btn--sm" style="color:var(--color-error);" onclick="removeCompat(' + itemId + ',' + c.model_year_engine_id + ')">Quitar</button></td></tr>';
});
html2 += '</tbody></table>';
@@ -777,6 +782,8 @@
window.cancelDraft = cancelDraft;
window.loadAlerts = loadAlerts;
window.printBarcode = printBarcode;
window.autoMatchCompat = autoMatchCompat;
window.removeCompat = removeCompat;
// =====================================================================
// INIT — load stock on page load

File diff suppressed because one or more lines are too long