Skip to Content
Menu
This question has been flagged

Hello.

I want to include chatter functionality with some JavaScript in an odoo 14 Addon.

For that I added the dependency for "mail" and require("mail.Chatter") in the js.

Then I get a warning:

Missing dependencies: ["mail.Chatter"]

Non loaded modules: ["addon_name"]


I don't know is missing. Most of search results are quite outdated.

manifest has the dependency:

{
    "depends": ["mail"],
"external_dependencies": {"python": ["extract_msg"]},
"data": ["views/templates.xml", "views/res_config_settings_views.xml"],
}


my template.xml

<odoo>
<data>
<template
id="assets_backend"
name="adddon_name assets"
inherit_id="web.assets_backend"
>

<xpath expr="." position="inside">
<script
type="text/javascript"
src="/addon_name/static/src/js/addon_name.js"
/>
</xpath>
</template>
</data>
</odoo>


and my addon_name.js has this:

odoo.define("addon_name", ['mail.Chatter'], function(require) {
    "use strict";

    var Chatter = require("mail.Chatter");

   Chatter.include({
        // my code        
    );
})



Thanks for your suggestions.

Avatar
Discard
Best Answer

Hi Ibrahim, in Odoo 14, all mails modules are migrated to new javascript odoo framework OWL ( https://github.com/odoo/owl ). You could look into modules like approvals & livechat to see how you should inherit from a component or a model.

Also have a look in form_renderer.js of mail module, this is where Chatter is loaded, it's kind of a specific way of doing, so maybe it can meet what you need exactly.

If you don't manage to achieve what you want to do, please give me more information and I'll try to give you more information.

 

Avatar
Discard
Best Answer

there is no syntax like odoo.define("addon_name", ['mail.Chatter'], function(require) { ... })

you should know that define is a function that takes 2 arguments : name of the module js and the function:

odoo.define("addon_name", function(require) {...})

Then the second problem is require("mail.Chatter"); 

there's no such js module. That's why odoo tells you that this dependancy is not found.


You may want to look at : addons/mail/static/src/components/chatter

That's for sure where you need to start. 

P.S : you said you need to extend but in your code you did a include.. the 2 are different.


Hope this helps.

Avatar
Discard
Author

Thank you for your answer.

Following the docs: https://www.odoo.com/documentation/14.0/reference/javascript_reference.html#javascript-module-system

There is this example:

"An alternative way to define a module is to give explicitly a list of dependencies in the second argument."

odoo.define('module.Something', ['module.A', 'module.B'], function (require) {

"use strict";

var A = require('module.A');

var B = require('module.B');

// some code

});

I was trying to follow this - but maybe I got it wrong.

But yes, that's basically the question: how to use this chatter from mail Addon.

(addons/mail/static/src/components/chatter)

I found this Addon (for odoo 13) which does pretty much what I need: https://github.com/OCA/social/tree/13.0/mail_drop_target

Importing the require("mail.Chatter");

Well. I guess "include chatter functionality" is more accurate.

Hi Benedikt,

1- odoo.define('module.Something', ['module.A', 'module.B'], function (require) {...}) : Thanks for the hint. I did not know that.

2- require("mail.Chatter");

This is true if you're on Odoo13 or less and The link to OCA module is for V13. You can find that the js module with name mail.Chatter does exist ( look at addons/mail/static/src/js/chatter.js ). Therefore, you can call it.

But in Odoo14, it ain't the case.

Gonna need to search more for the equivalent in the path i gave in my answer.

Good luck

Related Posts Replies Views Activity
0
May 23
2551
1
Jan 23
7285
1
Dec 22
2570
1
Dec 20
6914
2
Oct 20
7476