Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
3274 Vistas

I would like to have a confirmation window to avoid a mail is sent to the customer instead of an internal note on the chatter in Contacts app, when in the customer view.

I found the chatter is on  /odoo/odoo-server/addons/mail/static/src/components/composer and there in composer.xml,  in \mail.Composer.actionButtons" and tried to add  "confirm="Are you sure you want to send it ?" before  and  after the "  t-on-click="_onClickSend" ". But it does not work.

Any idea how to get it ?

Thanks.

Avatar
Descartar
Mejor respuesta

Today I was requested to make exactly this on this very same version, so here is my code in case someone else needs it:



Create a new javascript file with the next contents:

odoo.define('message_confirm/static/js/composer.js', function (require) {

'use strict';


const { patch } = require('web.utils');

const components = {

​Composer: require('mail/static/src/components/composer/composer.js'),

};


patch(components.Composer, 'message_confirm/static/js/composer.js', {

​ //--------------------------------------------------------------------------

​ // Private

​ //--------------------------------------------------------------------------


​ /**

​ * @override

​ */

​ _postMessage() {

​ if (confirm("Are you sure?") == true){

​ this._super();

​ }

​ },

});


});

*note that you may need to update the path and/or module names


Load the javascript in a view:

For some reasont it wont allow me to put html code in here, so just inherit the "web.assets_backend" view and load your javascript file


Add the view to the manifest:

"data": [

​'views/assets.xml',

],


And that's it. Hope it helps out somebody

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
1
feb 25
1026
2
dic 24
1942
0
nov 24
935
3
may 24
4221
0
ene 25
2334