Solución: Sobrescribir la función “display()” del archivo “modules/Opprtunities/views/view.edit.php” con este código
public function display()
{
global $mod_strings;
//javascript to make field mandatory
$jsscript = <<<EOQ
<script>
document.getElementById('btn_aos_products_opportunities_1_name').onclick = function()
{
var popup_request_data =
{
'call_back_function' : 'set_return',
'form_name' : 'EditView',
'field_to_name_array' :
{
'id' : 'aos_products_opportunities_1aos_products_ida',
'name' : 'aos_products_opportunities_1_name',
'price' : 'precio_del_producto_c',
}
};
open_popup('AOS_Products', 600, 400, '', true, false, popup_request_data);
}
/*************
SOBREESCRIBO LA FUNCION ser_return que viene por defecto en el CRM
***********/
function set_return(popup_reply_data) {
// console.log('Entro a esta funcion: set_return AAAAA');
from_popup_return = true;
var form_name = popup_reply_data.form_name;
var name_to_value_array = popup_reply_data.name_to_value_array;
for (var the_key in name_to_value_array) {
if (the_key == 'toJSON') {
/* just ignore */
}
else {
var displayValue = name_to_value_array[the_key].replace(/&/gi, '&').replace(/</gi, '<').replace(/>/gi, '>').replace(/'/gi, '\'').replace(/"/gi, '"');
/********
CONTROL EL TIPO DE VALOR
SI ES UN NUMERO LO REDONDEO A DOS DECIMALES
*******/
if (!isNaN(displayValue)) {
displayValue = parseFloat(displayValue).toFixed(2);
}
if (window.document.forms[form_name] && window.document.forms[form_name].elements[the_key]) {
window.document.forms[form_name].elements[the_key].value = displayValue;
SUGAR.util.callOnChangeListers(window.document.forms[form_name].elements[the_key]);
}
}
}
}
</script>
EOQ;
parent::display();
echo $jsscript; //echo the script
}
}