Skip to Content
Odoo Menu
  • Zaloguj się
  • Wypróbuj za darmo
  • Aplikacje
    Finanse
    • Księgowość
    • Fakturowanie
    • Wydatki
    • Arkusz kalkulacyjny (BI)
    • Dokumenty
    • Podpisy
    Sprzedaż
    • CRM
    • Sprzedaż
    • PoS Sklep
    • PoS Restauracja
    • Subskrypcje
    • Wypożyczalnia
    Strony Internetowe
    • Kreator Stron Internetowych
    • eCommerce
    • Blog
    • Forum
    • Czat na Żywo
    • eLearning
    Łańcuch dostaw
    • Magazyn
    • Produkcja
    • PLM
    • Zakupy
    • Konserwacja
    • Jakość
    Zasoby Ludzkie
    • Pracownicy
    • Rekrutacja
    • Urlopy
    • Ocena pracy
    • Polecenia Pracownicze
    • Flota
    Marketing
    • Marketing Społecznościowy
    • E-mail Marketing
    • SMS Marketing
    • Wydarzenia
    • Automatyzacja Marketingu
    • Ankiety
    Usługi
    • Projekt
    • Ewidencja czasu pracy
    • Usługi Terenowe
    • Helpdesk
    • Planowanie
    • Spotkania
    Produktywność
    • Dyskusje
    • Zatwierdzenia
    • IoT
    • VoIP
    • Baza wiedzy
    • WhatsApp
    Aplikacje trzecich stron Studio Odoo Odoo Cloud Platform
  • Branże
    Sprzedaż detaliczna
    • Księgarnia
    • Sklep odzieżowy
    • Sklep meblowy
    • Sklep spożywczy
    • Sklep z narzędziami
    • Sklep z zabawkami
    Żywienie i hotelarstwo
    • Bar i Pub
    • Restauracja
    • Fast Food
    • Pensjonat
    • Dystrybutor napojów
    • Hotel
    Agencja nieruchomości
    • Agencja nieruchomości
    • Biuro architektoniczne
    • Budowa
    • Zarządzanie nieruchomościami
    • Ogrodnictwo
    • Stowarzyszenie właścicieli nieruchomości
    Doradztwo
    • Biuro księgowe
    • Partner Odoo
    • Agencja marketingowa
    • Kancelaria prawna
    • Agencja rekrutacyjna
    • Audyt i certyfikacja
    Produkcja
    • Tekstylia
    • Metal
    • Meble
    • Jedzenie
    • Browar
    • Prezenty firmowe
    Zdrowie & Fitness
    • Klub sportowy
    • Salon optyczny
    • Centrum fitness
    • Praktycy Wellness
    • Apteka
    • Salon fryzjerski
    Transakcje
    • Złota rączka
    • Wsparcie Sprzętu IT
    • Systemy energii słonecznej
    • Szewc
    • Firma sprzątająca
    • Usługi HVAC
    Inne
    • Organizacja non-profit
    • Agencja Środowiskowa
    • Wynajem billboardów
    • Fotografia
    • Leasing rowerów
    • Sprzedawca oprogramowania
    Przeglądaj wszystkie branże
  • Community
    Ucz się
    • Samouczki
    • Dokumentacja
    • Certyfikacje
    • Szkolenie
    • Blog
    • Podcast
    Pomóż w nauce innym
    • Program Edukacyjny
    • Scale Up! Gra biznesowa
    • Odwiedź Odoo
    Skorzystaj z oprogramowania
    • Pobierz
    • Porównaj edycje
    • Wydania
    Współpracuj
    • Github
    • Forum
    • Wydarzenia
    • Tłumaczenia
    • Zostań partnerem
    • Usługi dla partnerów
    • Zarejestruj swoją firmę rachunkową
    Skorzystaj z usług
    • Znajdź partnera
    • Znajdź księgowego
    • Spotkaj się z doradcą
    • Usługi wdrożenia
    • Opinie klientów
    • Wsparcie
    • Aktualizacje
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Zaplanuj demo
  • Cennik
  • Pomoc

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

  • CRM
  • e-Commerce
  • Księgowość
  • Zapasy
  • PoS
  • Projekt
  • MRP
All apps
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Pomoc

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

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
chatteroverrideChatter18.0
2 Odpowiedzi
1099 Widoki
Awatar
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
Awatar
Odrzuć
minwolf999
Autor

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
Autor

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!

Awatar
minwolf999
Autor Najlepsza odpowiedź

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
Awatar
Odrzuć
Awatar
Cybrosys Techno Solutions Pvt.Ltd
Najlepsza odpowiedź

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
Awatar
Odrzuć
Podoba Ci się ta dyskusja? Dołącz do niej!

Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!

Zarejestruj się
Powiązane posty Odpowiedzi Widoki Czynność
Disable edit/delete messages in chatter
chatter Chatter
Awatar
Awatar
1
maj 25
2212
Change text of Log Note Button Rozwiązane
helpdesk chatter Chatter
Awatar
Awatar
1
lip 25
1294
How can I remove "Send Message Button" in Chatter? Rozwiązane
chatter v15 Chatter
Awatar
Awatar
2
lis 24
5123
Odoo10: default "unchecked" followers on chatter "New message" button click
javascript chatter override
Awatar
Awatar
2
maj 19
6778
What happened to Chatter in the Odoo 18 To-do App? Rozwiązane
missing Chatter 18.0 Todo
Awatar
Awatar
1
wrz 24
1937
Społeczność
  • Samouczki
  • Dokumentacja
  • Forum
Open Source
  • Pobierz
  • Github
  • Runbot
  • Tłumaczenia
Usługi
  • Hosting Odoo.sh
  • Wsparcie
  • Aktualizacja
  • Indywidualne rozwiązania
  • Edukacja
  • Znajdź księgowego
  • Znajdź partnera
  • Zostań partnerem
O nas
  • Nasza firma
  • Zasoby marki
  • Skontaktuj się z nami
  • Oferty pracy
  • Wydarzenia
  • Podcast
  • Blog
  • Klienci
  • Informacje prawne • Prywatność
  • Bezpieczeństwo Odoo
الْعَرَبيّة 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 to pakiet aplikacji biznesowych typu open source, które zaspokoją wszystkie potrzeby Twojej firmy: CRM, eCommerce, księgowość, inwentaryzacja, punkt sprzedaży, zarządzanie projektami itp.

Unikalną wartością Odoo jest to, że jest jednocześnie bardzo łatwe w użyciu i w pełni zintegrowane.

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