Search code examples
odooodoo-9

Override JS message in


This is how I tried to override function in a thread, generally, I just changed display_order: ORDER.ASC, to display_order: ORDER.DESC. Basically, my goal is just to change the order of messages in Discus. but my code has no effect, but I get a message in the log that it is running

  <template id="config.assets_backend" name="config assets" inherit_id="web.assets_backend" >
                    <xpath expr="." position="inside" >
                        <script type="text/javascript" src="/config/static/src/js/thread.js" ></script>
                    </xpath>
                </template>
 odoo.define('config.thread', function (require) {
        "use strict";

        var Thread  = require('mail.ChatThread');
         var ORDER = {
          ASC: 1,
         DESC: -1,
          };

        console.log("ChatThread: ", Thread);

        Thread.include({
            init: function (parent, options) {
                this._super.apply(this, arguments);
                this.options = _.defaults(options || {}, {
                    display_order: ORDER.DESC,
                });
            }
        });
    });

UPDATE for the bounty: As I tried to debug at this line this._super.apply(this, arguments); in arguments I receive display_order: 1 so my guess is that this line

this.options = _.defaults(options || {}, {
                    display_order: ORDER.DESC,
                });

not working properly. so any suggestions.


Solution

  • Here is solution for my problem:

    odoo.define('modulename.ChatThread',
        function (require) {
        "use strict";
        var core = require('web.core');
        var MailThread = require('mail.ChatThread');
        var Thread = MailThread.include({
        className: 'o_mail_thread',
        init: function (parent, options) {
            this._super.apply(this, arguments);
            this.options.display_order = -1;
        },
        });
    });