Hello everyone, I'm trying to change a rule in the Odoo loyalty program, the points one, but I'm just starting to program and I have some questions, how do I declare a file in the manifest to patch another Odoo file? How should it start? I'm sharing my sample files since at the moment I can't get it to load or detect the file. If there were examples and how they declare them in their manifesto, it would help me a lot, at least so I can recognize them. Logically, I'll worry about it later, hehe.
Thank you very much.
/** @odoo-module **/
// plealtad/static/src/js/patches/pos_order_loyalty.js
import { patch } from "@web/core/utils/patch";
import { Order } from "@point_of_sale/app/store/models";
alert('[Mascotier] Archivo JS cargado en POS OWL');
console.log('[Mascotier] pos_order_loyalty.js CARGADO ✔');
// Función de validación
function isLoyaltyAllowed(partner, programName = 'mascotier_rewards_points') {
if (!partner || !partner.x_partner_loy_active) {
console.warn(`[Mascotier] Partner ineligible para programa ${programName}`);
return false;
}
const program = partner.loyalty_programs?.find(p => p.name === programName);
return !!program;
}
// Guardar método original
const originalGetClaimableRewards = Order.prototype.getClaimableRewards;
// Aplicar patch
patch(Order.prototype, {
getClaimableRewards() {
console.log('[Mascotier] Ejecutando patch getClaimableRewards');
const partner = this.get_partner();
if (!isLoyaltyAllowed(partner)) {
return [];
}
return originalGetClaimableRewards.call(this);
},
});
MANIFEST:
'data': [
'views/customer_registration_template.xml',
'views/customer_dashboard_template.xml',
'views/customer_reset_pass_request_template.xml',
'views/customer_reset_pass_pin_template.xml',
'views/customer_reset_pass_update_template.xml',
'views/customer_login_template.xml',
'views/pin_verification_template.xml',
'security/ir.model.access.csv',
'data/copomex_data.xml',
'data/cron_cleanup.xml',
'data/cron_pin_cleanup.xml',
],
'assets': {
'web.assets_frontend': [
'plealtad/static/src/img/logo_mascotier.png',
'plealtad/static/src/js/fields_validation.js',
'plealtad/static/src/js/pin_timer.js',
],
'point_of_sale.assets': [
'plealtad/static/src/js/patches/pos_order_loyalty.js',
],
},
'installable': True,
'application': False,
'auto_install': False,
}