Overslaan naar inhoud
Odoo Menu
  • Aanmelden
  • Probeer het gratis
  • Apps
    Financiën
    • Boekhouding
    • Facturatie
    • Onkosten
    • Spreadsheet (BI)
    • Documenten
    • Ondertekenen
    Verkoop
    • CRM
    • Verkoop
    • Kassasysteem winkel
    • Kassasysteem Restaurant
    • Abonnementen
    • Verhuur
    Websites
    • Websitebouwer
    • E-commerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Bevoorradingsketen
    • Voorraad
    • Productie
    • PLM
    • Inkoop
    • Onderhoud
    • Kwaliteit
    Personeelsbeheer
    • Werknemers
    • Werving & Selectie
    • Verlof
    • Evaluaties
    • Aanbevelingen
    • Wagenpark
    Marketing
    • Social media Marketing
    • E-mailmarketing
    • SMS Marketing
    • Evenementen
    • Marketingautomatisering
    • Enquêtes
    Diensten
    • Project
    • Urenstaten
    • Buitendienst
    • Helpdesk
    • Planning
    • Afspraken
    Productiviteit
    • Chat
    • Goedkeuringen
    • IoT
    • VoIP
    • Kennis
    • WhatsApp
    Apps van derden Odoo Studio Odoo Cloud Platform
  • Bedrijfstakken
    Detailhandel
    • Boekhandel
    • kledingwinkel
    • Meubelzaak
    • Supermarkt
    • Bouwmarkt
    • Speelgoedwinkel
    Food & Hospitality
    • Bar en Pub
    • Restaurant
    • Fastfood
    • Guest House
    • Drankenhandelaar
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architectenbureau
    • Bouw
    • Vastgoedbeheer
    • Tuinieren
    • Vereniging van eigenaren
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketingbureau
    • Advocatenkantoor
    • Talentenwerving
    • Audit & Certificering
    Productie
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Relatiegeschenken
    Gezondheid & Fitness
    • Sportclub
    • Opticien
    • Fitnesscentrum
    • Wellness-medewerkers
    • Apotheek
    • Kapper
    Trades
    • Klusjesman
    • IT-hardware & support
    • Solar Energy Systems
    • Schoenmaker
    • Schoonmaakdiensten
    • HVAC Services
    Others
    • Nonprofit Organization
    • Milieuagentschap
    • Verhuur van Billboards
    • Fotograaf
    • Fietsleasing
    • Softwareverkoper
    Browse all Industries
  • Community
    Leren
    • Tutorials
    • Documentatie
    • Certificeringen
    • Training
    • Blog
    • Podcast
    Versterk het onderwijs
    • Onderwijs- programma
    • Scale Up! Business Game
    • Bezoek Odoo
    Download de Software
    • Downloaden
    • Vergelijk edities
    • Releases
    Werk samen
    • Github
    • Forum
    • Evenementen
    • Vertalingen
    • Word een Partner
    • Services for Partners
    • Registreer je accountantskantoor
    Diensten
    • Vind een partner
    • Vind een boekhouder
    • Een adviseur ontmoeten
    • Implementatiediensten
    • Klantreferenties
    • Ondersteuning
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Vraag een demo aan
  • Prijzen
  • Help

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Boekhouding
  • Voorraad
  • PoS
  • Project
  • MRP
All apps
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Help

Odoo 18: Override activity_ids in Chatter on res.partner form view

Inschrijven

Ontvang een bericht wanneer er activiteit is op deze post

Deze vraag is gerapporteerd
chatteroverrideChatter18.0
2 Antwoorden
1085 Weergaven
Avatar
minwolf999

Hi,

I'm working on Odoo 18.

Here's my issue: I need to display the activities from the child_ids of a contact in the Chatter component on the contact's view (res.partner).

To do this, I created a computed field all_activity_ids One2Many on res.partner, wich collects all the activities i want to display in the Chatter (including those from child_ids).

In short, i want to replace the default activity_ids field used by Chatter by my custom all_activity_ids, but only on the contact form view.

I thought about overriding activity_ids with the contents of my all_activity_ids, but that doesn't because activity filtrers should not include activities from the child contact.

I've tried different approaches using both JS and XML, but i haven't been able to achieve the expected result.

As a fallback, I also considered adding a second actvity list in the Chatter and disabling the default one for res.partner, but that didn't work either.

I don't know if I was cleared in the explication of my problem.

Does anyone have an idea of how I could achieve this properly ?

Thanks in advance !

0
Avatar
Annuleer
minwolf999
Auteur

Hi everyone,
I made some progress on my previous issue, but I’m stuck on the last part: realtime modification.
Here’s the problem:
When I mark an activity as done (only if it belongs to a child_ids), the confirmation popup stays open, and I can mark the activity as done infinitely without refreshing the page.
Here’s the solution I have so far:

/** @odoo-module **/

import { onWillStart } from "@odoo/owl";
import { patch } from "@web/core/utils/patch";
import { Chatter } from "@mail/chatter/web_portal/chatter";

patch(Chatter.prototype, {
setup() {
super.setup();

onWillStart(async () => {
if (this.props?.threadModel !== "res.partner") return;

const ids = this._getAllActivityIds();
if (!ids.length) return;

await this._primeActivities(ids);
});
},

get activities() {
console.log('[ChatterPatch] get activities');

if (this.props.threadModel !== "res.partner") return this.state?.thread?.activities ?? [];

const baseActivities = this.state?.thread?.activities ?? [];
const ids = [...new Set(this._getAllActivityIds())];
const baseMap = new Map(baseActivities.map(a => [a.id, a]));
const resolved = this._resolveFromStore(ids);
const extras = resolved.filter(a => a && !baseMap.has(a.id));

return [...baseActivities, ...extras];
},

// private methods
_getMailStore() {
const s = this?.env?.services;
if (s && (s["mail.store"] || s.mailStore)) return s["mail.store"] || s.mailStore;
const ts = this?.state?.thread?.store;
if (ts) return ts;
try {
const dbg = window.odoo?.__DEBUG__?.services;
if (dbg && (dbg["mail.store"] || dbg.mailStore)) return dbg["mail.store"] || dbg.mailStore;
} catch {}
return null;
},

async _primeActivities(ids) {
const store = this._getMailStore();
const orm = this?.env?.services?.orm;
if (!store || !orm || !ids?.length) return;

const have = (id) =>
(store.Activity?.get?.(id)) ||
(store.activityById?.[id]) ||
(store.activities instanceof Map ? store.activities.get(id) : null);

const missing = ids.filter((id) => !have(id));
if (!missing.length) return;

const fieldsInfo = await orm.call("mail.activity", "fields_get", [], {});
const fieldNames = Object.keys(fieldsInfo);

const activities = await orm.read("mail.activity", missing, fieldNames);
if (!activities?.length) return;

if (store.Activity?.insertFromServer) store.Activity.insertFromServer(activities);
else if (store.Activity?.insert) store.Activity.insert(activities);

this._rowsByActId = new Map(activities.map(a => [a.id, a]));
const userIds = [...new Set(activities
.map(a => Array.isArray(a.user_id) ? a.user_id[0] : a.user_id)
.filter(Boolean))];
if (!userIds.length) return;

const userRows = await orm.read("res.users", userIds, ["partner_id", "name"]);
const partnerIds = [...new Set(userRows
.map(u => Array.isArray(u.partner_id) ? u.partner_id[0] : u.partner_id)
.filter(Boolean))];
if (!partnerIds.length) return;

const partners = await orm.read("res.partner", partnerIds, ["id", "name", "display_name", "email"]);
this._personaByPartnerId = new Map(partners.map(p => {
const avatarUrl = `/web/image/res.partner/${p.id}/avatar_128`;
return [p.id, {
id: p.id,
name: p.display_name || p.name,
display_name: p.display_name || p.name,
email: p.email,
avatarUrl,
}];
}));
},

_resolveFromStore(ids) {
const store = this._getMailStore();
let arr = [];
if (store?.Activity?.get) arr = ids.map(id => store.Activity.get(id)).filter(Boolean);
if (!arr.length && store?.Activity?.findFromIdentifyingData)
arr = ids.map(id => store.Activity.findFromIdentifyingData({ id })).filter(Boolean);
if (!arr.length && store?.activityById)
arr = ids.map(id => store.activityById[id]).filter(Boolean);
if (!arr.length && store?.activities instanceof Map)
arr = ids.map(id => store.activities.get(id)).filter(Boolean);

const rowsById = this._rowsByActId || new Map();
const personaByPartnerId = this._personaByPartnerId || new Map();
const defaultPersona = this._defaultPersona || {
id: 0, name: "User", display_name: "User",
avatarUrl: (store?.DEFAULT_AVATAR) || "/mail/static/src/img/smiley/avatar.jpg",
};

for (const a of arr) {
if (a && !a.persona) {
const row = rowsById.get(a.id);
let partnerId = null;
let userName = null;
if (row?.user_id) {
partnerId = Array.isArray(row.user_id) ? row.user_id[0] : null;
userName = Array.isArray(row.user_id) ? row.user_id[1] : null;
}
const persona = partnerId && personaByPartnerId.get(partnerId)
? personaByPartnerId.get(partnerId)
: defaultPersona;
if (userName && persona === defaultPersona) {
a.persona = { ...defaultPersona, name: userName, display_name: userName };
} else {
a.persona = persona;
}
}
}

return arr;
},

_getAllActivityIds() {
const rel = this.props?.webRecord?.data?.all_activity_ids;
if (!rel) return [];

if (Array.isArray(rel._currentIds)) return rel._currentIds.slice();
if (Array.isArray(rel.records)) return rel.records.map(r => r.id).filter(Boolean);
if (Array.isArray(rel.res_ids)) return rel.res_ids;
if (Array.isArray(rel)) return rel;
return [];
}
});

minwolf999
Auteur

Hi everyone,
I finally found a solution to my issue, so I’m sharing it here in case it helps someone else:

/** @odoo-module **/

import { onWillStart } from "@odoo/owl";
import { patch } from "@web/core/utils/patch";

import { Activity } from "@mail/core/web/activity";
import { Chatter } from "@mail/chatter/web_portal/chatter";
import { ActivityMarkAsDone } from "@mail/core/web/activity_markasdone_popover";

let chatter = null;
const deleted_ids = [];

patch(Activity.prototype, {
setup() {
super.setup();
},

async edit() {
await super.edit();

const id = this.props.activity.id;
const [updated] = await this.orm.read("mail.activity", [id]);

const store = chatter._getMailStore();
if (store.Activity?.insertFromServer) store.Activity.insertFromServer([updated]);
else if (store.Activity?.insert) store.Activity.insert([updated]);

chatter?.reload();
},

async unlink() {
await super.unlink();

deleted_ids.push(this.props.activity.id);
chatter?.reload();
},
});

patch(ActivityMarkAsDone.prototype, {
async onClickDone() {
await super.onClickDone();

deleted_ids.push(this.props.activity.id);
chatter?.reload();
}
});

patch(Chatter.prototype, {
setup() {
super.setup();
chatter = this;

onWillStart(async () => {
if (this.props?.threadModel !== "res.partner") return;

const ids = this._getAllActivityIds();
if (!ids.length) return;

await this._primeActivities(ids);
});
},

get activities() {
if (this.props.threadModel !== "res.partner") return this.state?.thread?.activities ?? [];

const baseActivities = this.state?.thread?.activities ?? [];
const ids = [...new Set(this._getAllActivityIds())];
const baseMap = new Map(baseActivities.map(a => [a.id, a]));
const resolved = this._resolveFromStore(ids);
const extras = resolved.filter(a => a && !baseMap.has(a.id));

return [...baseActivities, ...extras];
},

async reload() {
if (this.props.threadModel !== "res.partner") return;

this.render();
},

// private methods
_getMailStore() {
const s = this?.env?.services;
if (s && (s["mail.store"] || s.mailStore)) return s["mail.store"] || s.mailStore;
const ts = this?.state?.thread?.store;
if (ts) return ts;
try {
const dbg = window.odoo?.__DEBUG__?.services;
if (dbg && (dbg["mail.store"] || dbg.mailStore)) return dbg["mail.store"] || dbg.mailStore;
} catch {}
return null;
},

async _primeActivities(ids) {
const store = this._getMailStore();
const orm = this?.env?.services?.orm;
if (!store || !orm || !ids?.length) return;

const have = (id) =>
(store.Activity?.get?.(id)) ||
(store.activityById?.[id]) ||
(store.activities instanceof Map ? store.activities.get(id) : null);

const missing = ids.filter((id) => !have(id));
if (!missing.length) return;

const fieldsInfo = await orm.call("mail.activity", "fields_get", [], {});
const fieldNames = Object.keys(fieldsInfo);

const activities = await orm.read("mail.activity", missing, fieldNames);
if (!activities?.length) return;

if (store.Activity?.insertFromServer) store.Activity.insertFromServer(activities);
else if (store.Activity?.insert) store.Activity.insert(activities);

this._rowsByActId = new Map(activities.map(a => [a.id, a]));
const userIds = [...new Set(activities
.map(a => Array.isArray(a.user_id) ? a.user_id[0] : a.user_id)
.filter(Boolean))];
if (!userIds.length) return;

const userRows = await orm.read("res.users", userIds, ["partner_id", "name"]);
const partnerIds = [...new Set(userRows
.map(u => Array.isArray(u.partner_id) ? u.partner_id[0] : u.partner_id)
.filter(Boolean))];
if (!partnerIds.length) return;

const partners = await orm.read("res.partner", partnerIds, ["id", "name", "display_name", "email"]);
this._personaByPartnerId = new Map(partners.map(p => {
const avatarUrl = `/web/image/res.partner/${p.id}/avatar_128`;
return [p.id, {
id: p.id,
name: p.display_name || p.name,
display_name: p.display_name || p.name,
email: p.email,
avatarUrl,
}];
}));
},

_resolveFromStore(ids) {
const store = this._getMailStore();
let arr = [];
if (store?.Activity?.get) arr = ids.map(id => store.Activity.get(id)).filter(Boolean);
if (!arr.length && store?.Activity?.findFromIdentifyingData)
arr = ids.map(id => store.Activity.findFromIdentifyingData({ id })).filter(Boolean);
if (!arr.length && store?.activityById)
arr = ids.map(id => store.activityById[id]).filter(Boolean);
if (!arr.length && store?.activities instanceof Map)
arr = ids.map(id => store.activities.get(id)).filter(Boolean);

const rowsById = this._rowsByActId || new Map();
const personaByPartnerId = this._personaByPartnerId || new Map();
const defaultPersona = this._defaultPersona || {
id: 0, name: "User", display_name: "User",
avatarUrl: (store?.DEFAULT_AVATAR) || "/mail/static/src/img/smiley/avatar.jpg",
};

for (const a of arr) {
if (a && !a.persona) {
const row = rowsById.get(a.id);
let partnerId = null;
let userName = null;
if (row?.user_id) {
partnerId = Array.isArray(row.user_id) ? row.user_id[0] : null;
userName = Array.isArray(row.user_id) ? row.user_id[1] : null;
}
const persona = partnerId && personaByPartnerId.get(partnerId)
? personaByPartnerId.get(partnerId)
: defaultPersona;
if (userName && persona === defaultPersona) {
a.persona = { ...defaultPersona, name: userName, display_name: userName };
} else {
a.persona = persona;
}
}
}

return arr;
},

_getAllActivityIds() {
const rel = this.props?.webRecord?.data?.all_activity_ids;
if (!rel) return [];

var res;
if (Array.isArray(rel._currentIds)) res = rel._currentIds.slice();
else if (Array.isArray(rel.records)) res = rel.records.map(r => r.id).filter(Boolean);
else if (Array.isArray(rel.res_ids)) res = rel.res_ids;
else if (Array.isArray(rel)) res = rel;
else return [];

return res.filter(id => !deleted_ids.includes(id))
}
});

Thanks for your help!

Avatar
minwolf999
Auteur Beste antwoord

Hi,
Thanks for your reply!
It helped me a bit, but I had already tried similar approaches without success.
What I’m struggling with is how to properly replace the default activity_ids​ field used by the Chatter, through JavaScript (OWL).

/** @odoo-module **/


import { patch } from '@web/core/utils/patch';

import { Chatter } from '@mail/chatter/web_portal/chatter';


console.log("[chatterPatcher] File loaded");


patch(Chatter.prototype, {

setup() {

super.setup();


if (this.props.record && this.props.record.resModel === 'res.partner') {

console.log("⏳ Switching chatter to use all_activity_ids for res.partner");

this.props.activityField = 'all_activity_ids';

}

}

})

The patch seems to run, but the Chatter still uses activity_ids​ instead of my all_activity_ids​.
Has anyone managed to override the activityField​ properly via OWL?
Any working example or pointer would be much appreciated!
Thanks again!

0
Avatar
Annuleer
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Beste antwoord

Hi,


In Odoo 18, the Chatter widget is designed to only display activities (activity_ids) that belong directly to the current record. This makes it difficult to include activities from child contacts (child_ids) when viewing a parent contact. Overriding the existing activity_ids field does not work properly, because it is a core computed field on mail.thread and Odoo relies on it for filters, reminders, and activity domains. If you override it to merge child activities, the built-in logic for things like “My Activities” or overdue activities will no longer function correctly.


To achieve the desired behavior, one option is to create a custom field such as all_activity_ids on res.partner, which combines the partner’s own activities with those of its children. The challenge is that the Chatter component always points to activity_ids by default, so replacing it requires a small JavaScript (OWL) extension to override the Chatter view specifically for partners. This method is the cleanest if you want full integration, but it involves frontend customization.


Another approach is to hide the standard activity list in Chatter for contacts and add a custom widget or section that displays all_activity_ids. This way, you still see the merged activities in the form view, without breaking the default behavior of Chatter. It requires less invasive changes but does mean contacts will have a slightly different layout compared to other models.


As a simpler fallback, you can add a smart button or a new tab on the contact form that shows all activities, combining those from the parent and child contacts. This avoids touching the Chatter at all, is much easier to implement, and still gives end users visibility of everything in one place. In short, if you need deep integration inside Chatter you will need to extend it with JavaScript, but if visibility is enough then a smart button or separate tab is safer and quicker to implement.



Hope it helps

0
Avatar
Annuleer
Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!

Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!

Aanmelden
Gerelateerde posts Antwoorden Weergaven Activiteit
Disable edit/delete messages in chatter
chatter Chatter
Avatar
Avatar
1
mei 25
2185
Change text of Log Note Button Opgelost
helpdesk chatter Chatter
Avatar
Avatar
1
jul. 25
1279
How can I remove "Send Message Button" in Chatter? Opgelost
chatter v15 Chatter
Avatar
Avatar
2
nov. 24
5095
Odoo10: default "unchecked" followers on chatter "New message" button click
javascript chatter override
Avatar
Avatar
2
mei 19
6774
What happened to Chatter in the Odoo 18 To-do App? Opgelost
missing Chatter 18.0 Todo
Avatar
Avatar
1
sep. 24
1925
Community
  • Tutorials
  • Documentatie
  • Forum
Open Source
  • Downloaden
  • Github
  • Runbot
  • Vertalingen
Diensten
  • Odoo.sh Hosting
  • Ondersteuning
  • Upgrade
  • Gepersonaliseerde ontwikkelingen
  • Onderwijs
  • Vind een boekhouder
  • Vind een partner
  • Word een Partner
Over ons
  • Ons bedrijf
  • Merkelementen
  • Neem contact met ons op
  • Vacatures
  • Evenementen
  • Podcast
  • Blog
  • Klanten
  • Juridisch • Privacy
  • Beveiliging
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo is een suite van open source zakelijke apps die aan al je bedrijfsbehoeften voldoet: CRM, E-commerce, boekhouding, inventaris, kassasysteem, projectbeheer, enz.

Odoo's unieke waardepropositie is om tegelijkertijd zeer gebruiksvriendelijk en volledig geïntegreerd te zijn.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now