Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Schvalování
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Food & Hospitality
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Guest House
    • Distributor nápojů
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Trades
    • Údržbář
    • IT hardware a podpora
    • Solar Energy Systems
    • Výrobce obuvi
    • Úklidové služby
    • HVAC Services
    Others
    • Nonprofit Organization
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Browse all Industries
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Services for Partners
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účetnictví
  • Sklad
  • PoS
  • Projekty
  • MRP
All apps
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

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

Odebírat

Get notified when there's activity on this post

This question has been flagged
chatteroverrideChatter18.0
2 Odpovědi
1124 Zobrazení
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
Zrušit
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!

Avatar
minwolf999
Autor Nejlepší odpověď

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
Zrušit
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Nejlepší odpověď

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
Zrušit
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
Disable edit/delete messages in chatter
chatter Chatter
Avatar
Avatar
1
kvě 25
2236
Change text of Log Note Button Vyřešeno
helpdesk chatter Chatter
Avatar
Avatar
1
čvc 25
1313
How can I remove "Send Message Button" in Chatter? Vyřešeno
chatter v15 Chatter
Avatar
Avatar
2
lis 24
5147
Odoo10: default "unchecked" followers on chatter "New message" button click
javascript chatter override
Avatar
Avatar
2
kvě 19
6782
What happened to Chatter in the Odoo 18 To-do App? Vyřešeno
missing Chatter 18.0 Todo
Avatar
Avatar
1
zář 24
1953
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 je balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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