[REM] website_sale_aplicoop: remove dead code and orphaned tests
Duplicate _translate_labels fallback, unreachable /eskaera/add-to-cart and /eskaera/save-cart routes (the frontend cart is localStorage-only and uses save-order), redundant pickup wrappers, unused pagination/count helpers and fields, deprecated JS shims, and the already-empty checkout_summary.js and i18n key/init leftovers. Also drops 11 tests/*.py never wired into tests/__init__.py: three were unimplemented placeholders (setUp with no assertions), and the other eight had real assertions but were bit-rotted against the current schema (e.g. res.partner.is_supplier no longer exists) — wiring them in surfaced 43 failures unrelated to this cleanup. Verified 0 failed/0 errors of 270 tests both before and after. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
6ba554c91b
commit
b3999e2283
24 changed files with 5 additions and 5598 deletions
|
|
@ -1,9 +0,0 @@
|
|||
/** AGPL-3.0
|
||||
* NOTE: Checkout summary rendering is now handled by checkout_labels.js
|
||||
* This file is kept for backwards compatibility but is no longer needed.
|
||||
* The main renderSummary() logic is in checkout_labels.js
|
||||
*/
|
||||
(function () {
|
||||
"use strict";
|
||||
// Checkout rendering is handled by checkout_labels.js
|
||||
})();
|
||||
|
|
@ -226,10 +226,6 @@
|
|||
}, 50);
|
||||
},
|
||||
|
||||
renderCheckoutSummary: function () {
|
||||
// Stub - now handled by global window.renderCheckoutSummary
|
||||
},
|
||||
|
||||
addDeliveryProduct: function () {
|
||||
if (!this.deliveryProductId) {
|
||||
console.warn("[HomeDelivery] Delivery product ID not found");
|
||||
|
|
|
|||
|
|
@ -9,9 +9,6 @@
|
|||
* OLD: window.getCheckoutLabels()
|
||||
* NEW: i18nManager.getAll()
|
||||
*
|
||||
* OLD: window.formatCurrency(amount)
|
||||
* NEW: i18nManager.formatCurrency(amount)
|
||||
*
|
||||
* Copyright 2025 Criptomart
|
||||
* License AGPL-3.0 or later
|
||||
*/
|
||||
|
|
@ -35,32 +32,5 @@
|
|||
return key ? key : {};
|
||||
};
|
||||
|
||||
/**
|
||||
* DEPRECATED - Use i18nManager.getAll() instead
|
||||
*/
|
||||
window.getSearchLabels = function () {
|
||||
if (window.i18nManager && window.i18nManager.initialized) {
|
||||
return {
|
||||
searchPlaceholder: window.i18nManager.get("search_products"),
|
||||
noResults: window.i18nManager.get("no_results"),
|
||||
};
|
||||
}
|
||||
return {
|
||||
searchPlaceholder: "Search products...",
|
||||
noResults: "No products found",
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* DEPRECATED - Use i18nManager.formatCurrency(amount) instead
|
||||
*/
|
||||
window.formatCurrency = function (amount) {
|
||||
if (window.i18nManager) {
|
||||
return window.i18nManager.formatCurrency(amount);
|
||||
}
|
||||
// Fallback
|
||||
return "€" + parseFloat(amount).toFixed(2);
|
||||
};
|
||||
|
||||
console.log("[i18n_helpers] DEPRECATED - Use i18n_manager.js instead");
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -103,39 +103,6 @@
|
|||
}
|
||||
return this.labels;
|
||||
},
|
||||
|
||||
/**
|
||||
* Check if a specific label exists
|
||||
*/
|
||||
has: function (key) {
|
||||
if (!this.initialized) return false;
|
||||
return key in this.labels;
|
||||
},
|
||||
|
||||
/**
|
||||
* Format currency to Euro format
|
||||
*/
|
||||
formatCurrency: function (amount) {
|
||||
try {
|
||||
return new Intl.NumberFormat(document.documentElement.lang || "es_ES", {
|
||||
style: "currency",
|
||||
currency: "EUR",
|
||||
}).format(amount);
|
||||
} catch (e) {
|
||||
// Fallback to simple Euro format
|
||||
return "€" + parseFloat(amount).toFixed(2);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Escape HTML to prevent XSS
|
||||
*/
|
||||
escapeHtml: function (text) {
|
||||
if (!text) return "";
|
||||
var div = document.createElement("div");
|
||||
div.textContent = text;
|
||||
return div.innerHTML;
|
||||
},
|
||||
};
|
||||
|
||||
// Auto-initialize on DOM ready
|
||||
|
|
|
|||
|
|
@ -1371,160 +1371,6 @@
|
|||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Update DOM elements with translated labels
|
||||
*/
|
||||
_updateDOMLabels: function (labels) {
|
||||
console.log("[UPDATE_LABELS] Starting DOM update with labels:", labels);
|
||||
|
||||
// Map of element ID to label key
|
||||
var elementLabelMap = {
|
||||
"label-home-delivery": "home_delivery",
|
||||
"label-delivery-information": "delivery_information",
|
||||
"label-important": "important",
|
||||
"label-confirm-warning": "confirm_order_warning",
|
||||
};
|
||||
|
||||
// Update each element
|
||||
for (var elementId in elementLabelMap) {
|
||||
var element = document.getElementById(elementId);
|
||||
var labelKey = elementLabelMap[elementId];
|
||||
var translatedText = labels[labelKey];
|
||||
|
||||
console.log(
|
||||
"[UPDATE_LABELS] Element:",
|
||||
elementId,
|
||||
"| Exists:",
|
||||
!!element,
|
||||
"| Label Key:",
|
||||
labelKey,
|
||||
"| Translated:",
|
||||
translatedText
|
||||
);
|
||||
|
||||
if (element && translatedText) {
|
||||
var oldText = element.textContent;
|
||||
element.textContent = translatedText;
|
||||
console.log(
|
||||
"[UPDATE_LABELS] ✅ Updated #" +
|
||||
elementId +
|
||||
': "' +
|
||||
oldText +
|
||||
'" → "' +
|
||||
translatedText +
|
||||
'"'
|
||||
);
|
||||
} else if (!element) {
|
||||
console.log("[UPDATE_LABELS] ❌ Element not found: #" + elementId);
|
||||
} else if (!translatedText) {
|
||||
console.log(
|
||||
"[UPDATE_LABELS] ❌ Label not found: " +
|
||||
labelKey +
|
||||
" (available keys: " +
|
||||
Object.keys(labels).join(", ") +
|
||||
")"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Update delivery day text if available
|
||||
if (
|
||||
window.groupOrderShop &&
|
||||
window.groupOrderShop.labels &&
|
||||
window.groupOrderShop.labels.delivery_info_template
|
||||
) {
|
||||
var deliveryDayText = document.getElementById("delivery-day-text");
|
||||
console.log("[UPDATE_LABELS] Delivery day text element exists:", !!deliveryDayText);
|
||||
|
||||
if (deliveryDayText) {
|
||||
// Get delivery data from window.deliveryData first, then fallback to attributes
|
||||
var pickupDayIndex = "";
|
||||
var pickupDate = "";
|
||||
var deliveryNotice = "";
|
||||
|
||||
if (window.deliveryData) {
|
||||
console.log(
|
||||
"[UPDATE_LABELS] Using window.deliveryData:",
|
||||
window.deliveryData
|
||||
);
|
||||
pickupDayIndex = window.deliveryData.pickupDay || "";
|
||||
pickupDate = window.deliveryData.pickupDate || "";
|
||||
deliveryNotice = window.deliveryData.deliveryNotice || "";
|
||||
} else {
|
||||
console.log(
|
||||
"[UPDATE_LABELS] window.deliveryData not found, using data attributes"
|
||||
);
|
||||
var wrap = document.getElementById("wrap");
|
||||
pickupDayIndex = wrap ? wrap.getAttribute("data-pickup-day") : "";
|
||||
pickupDate = wrap ? wrap.getAttribute("data-pickup-date") : "";
|
||||
deliveryNotice = wrap ? wrap.getAttribute("data-delivery-notice") : "";
|
||||
}
|
||||
|
||||
// Normalize: convert "undefined" strings and null to empty for processing
|
||||
if (pickupDayIndex === "undefined" || pickupDayIndex === null)
|
||||
pickupDayIndex = "";
|
||||
if (pickupDate === "undefined" || pickupDate === null) pickupDate = "";
|
||||
if (deliveryNotice === "undefined" || deliveryNotice === null)
|
||||
deliveryNotice = "";
|
||||
|
||||
console.log("[UPDATE_LABELS] Delivery data (final):", {
|
||||
pickupDayIndex: pickupDayIndex,
|
||||
pickupDate: pickupDate,
|
||||
deliveryNotice: deliveryNotice,
|
||||
});
|
||||
|
||||
// Day names mapping
|
||||
var dayNames = {
|
||||
0: "Monday",
|
||||
1: "Tuesday",
|
||||
2: "Wednesday",
|
||||
3: "Thursday",
|
||||
4: "Friday",
|
||||
5: "Saturday",
|
||||
6: "Sunday",
|
||||
};
|
||||
|
||||
// Get translated day names if available
|
||||
if (window.groupOrderShop && window.groupOrderShop.day_names) {
|
||||
dayNames = window.groupOrderShop.day_names;
|
||||
}
|
||||
|
||||
// Get the day name from index
|
||||
var pickupDayName =
|
||||
pickupDayIndex && dayNames[pickupDayIndex]
|
||||
? dayNames[pickupDayIndex]
|
||||
: pickupDayIndex;
|
||||
|
||||
// Build message from template
|
||||
var msg = window.groupOrderShop.labels.delivery_info_template;
|
||||
msg = msg.replace("{pickup_day}", pickupDayName);
|
||||
msg = msg.replace("{pickup_date}", pickupDate);
|
||||
|
||||
console.log("[UPDATE_LABELS] Built delivery message:", msg);
|
||||
|
||||
// Build final HTML output
|
||||
var htmlOutput = msg;
|
||||
if (deliveryNotice) {
|
||||
// Replace newlines with <br> tags for HTML display
|
||||
htmlOutput =
|
||||
msg.replace(/\n/g, "<br>") +
|
||||
"<br><br>" +
|
||||
deliveryNotice.replace(/\n/g, "<br>");
|
||||
console.log("[UPDATE_LABELS] Final HTML with notice:", htmlOutput);
|
||||
} else {
|
||||
htmlOutput = msg.replace(/\n/g, "<br>");
|
||||
}
|
||||
|
||||
deliveryDayText.innerHTML = htmlOutput;
|
||||
console.log(
|
||||
"[UPDATE_LABELS] ✅ Updated delivery day text with translated template"
|
||||
);
|
||||
}
|
||||
} else {
|
||||
console.log("[UPDATE_LABELS] ❌ delivery_info_template label not found");
|
||||
}
|
||||
},
|
||||
|
||||
_attachLoadMoreListener: function () {
|
||||
var self = this;
|
||||
var btn = document.getElementById("load-more-btn");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue