There is a file in Odoo: addons/mail/static/src/js/chatter.js . It contains a method I would like to change: message_get_suggested_recipients.
For this I created an addon with files:
chatter.xml
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<!--template id="assets_backend" name="addon1" inherit_id="web.assets_backend"-->
<xpath expr="." position="inside">
<script type="text/javascript" src="/addon1/static/src/js/chatter.js"></script>
</xpath>
</template>
</data>
</odoo>
and
chatter.js
odoo.define('addon1.chatter', function(require){
'use strict';
var OdooChatter = require('mail.Chatter');
OdooChatter.include({
message_get_suggested_recipients: function () {
var self = this;
var email_addresses = _.pluck(this.suggested_partners, 'email_address');
return this.thread_dataset
.call('message_get_suggested_recipients', [[this.context.default_res_id], this.context])
.done(function (suggested_recipients) {
var thread_recipients = suggested_recipients[self.context.default_res_id];
_.each(thread_recipients, function (recipient) {
var parsed_email = utils.parse_email(recipient[1]);
if (_.indexOf(email_addresses, parsed_email[1]) === -1) {
self.suggested_partners.push({
checked: recipient[3] || true,
partner_id: recipient[0],
full_name: recipient[1],
name: parsed_email[0],
email_address: parsed_email[1],
reason: recipient[2],
});
}
});
});
}
});
});
I can see that javascript loads when Odoo website is open, but breakpoints don't catch the right place, that means loaded javascript was ineffective.
How to change the method because my provided method isn't called (instead the original is called)?
Modify your chatter.xml file as:
This works in my case on Odoo 11. In your case (Odoo 10) it should work as well.
After re-looking at the Odoo's source code, because you'd like to override the
message_get_suggested_recipients
which is a prop ofmail.composer.BasicComposer
(and notmail.Chatter
) I think yourinclude
should be: