Skip ke Konten
Odoo Menu
  • Login
  • Uji coba gratis
  • Aplikasi
    Keuangan
    • Akuntansi
    • Faktur
    • Pengeluaran
    • Spreadsheet (BI)
    • Dokumen
    • Tanda Tangan
    Sales
    • CRM
    • Sales
    • POS Toko
    • POS Restoran
    • Langganan
    • Rental
    Website
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Rantai Pasokan
    • Inventaris
    • Manufaktur
    • PLM
    • Purchase
    • Maintenance
    • Kualitas
    Sumber Daya Manusia
    • Karyawan
    • Rekrutmen
    • Cuti
    • Appraisal
    • Referensi
    • Armada
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Acara
    • Otomatisasi Marketing
    • Survei
    Layanan
    • Project
    • Timesheet
    • Layanan Lapangan
    • Meja Bantuan
    • Planning
    • Appointment
    Produktivitas
    • Diskusi
    • Approval
    • IoT
    • VoIP
    • Pengetahuan
    • WhatsApp
    Aplikasi pihak ketiga Odoo Studio Platform Odoo Cloud
  • Industri-Industri
    Retail
    • Toko Buku
    • Toko Baju
    • Toko Furnitur
    • Toko Kelontong
    • Toko Hardware
    • Toko Mainan
    Makanan & Hospitality
    • Bar dan Pub
    • Restoran
    • Fast Food
    • Rumah Tamu
    • Distributor Minuman
    • Hotel
    Real Estate
    • Agensi Real Estate
    • Firma Arsitektur
    • Konstruksi
    • Estate Management
    • Perkebunan
    • Asosiasi Pemilik Properti
    Konsultansi
    • Firma Akuntansi
    • Mitra Odoo
    • Agensi Marketing
    • Firma huku
    • Talent Acquisition
    • Audit & Sertifikasi
    Manufaktur
    • Tekstil
    • Logam
    • Perabotan
    • Makanan
    • Brewery
    • Corporate Gift
    Kesehatan & Fitness
    • Sports Club
    • Toko Kacamata
    • Fitness Center
    • Wellness Practitioners
    • Farmasi
    • Salon Rambut
    Perdagangan
    • Handyman
    • IT Hardware & Support
    • Sistem-Sistem Energi Surya
    • Pembuat Sepatu
    • Cleaning Service
    • Layanan HVAC
    Lainnya
    • Organisasi Nirlaba
    • Agen Lingkungan
    • Rental Billboard
    • Fotografi
    • Penyewaan Sepeda
    • Reseller Software
    Browse semua Industri
  • Komunitas
    Belajar
    • Tutorial-tutorial
    • Dokumentasi
    • Sertifikasi
    • Pelatihan
    • Blog
    • Podcast
    Empower Education
    • Program Edukasi
    • Game Bisnis 'Scale Up!'
    • Kunjungi Odoo
    Dapatkan Softwarenya
    • Download
    • Bandingkan Edisi
    • Daftar Rilis
    Kolaborasi
    • Github
    • Forum
    • Acara
    • Terjemahan
    • Menjadi Partner
    • Layanan untuk Partner
    • Daftarkan perusahaan Akuntansi Anda.
    Dapatkan Layanan
    • Temukan Mitra
    • Temukan Akuntan
    • Temui penasihat
    • Layanan Implementasi
    • Referensi Pelanggan
    • Bantuan
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dapatkan demo
  • Harga
  • Bantuan

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

  • CRM
  • e-Commerce
  • Akuntansi
  • Inventaris
  • PoS
  • Project
  • MRP
All apps
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Help

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

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
chatteroverrideChatter18.0
2 Replies
1112 Tampilan
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
Buang
minwolf999
Penulis

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
Penulis

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
Penulis Jawaban Terbai

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
Buang
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Jawaban Terbai

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
Buang
Menikmati diskusi? Jangan hanya membaca, ikuti!

Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!

Daftar
Post Terkait Replies Tampilan Aktivitas
Disable edit/delete messages in chatter
chatter Chatter
Avatar
Avatar
1
Mei 25
2222
Change text of Log Note Button Diselesaikan
helpdesk chatter Chatter
Avatar
Avatar
1
Jul 25
1308
How can I remove "Send Message Button" in Chatter? Diselesaikan
chatter v15 Chatter
Avatar
Avatar
2
Nov 24
5137
Odoo10: default "unchecked" followers on chatter "New message" button click
javascript chatter override
Avatar
Avatar
2
Mei 19
6782
What happened to Chatter in the Odoo 18 To-do App? Diselesaikan
missing Chatter 18.0 Todo
Avatar
Avatar
1
Sep 24
1948
Komunitas
  • Tutorial-tutorial
  • Dokumentasi
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Terjemahan
Layanan
  • Odoo.sh Hosting
  • Bantuan
  • Peningkatan
  • Custom Development
  • Pendidikan
  • Temukan Akuntan
  • Temukan Mitra
  • Menjadi Partner
Tentang Kami
  • Perusahaan kami
  • Aset Merek
  • Hubungi kami
  • Tugas
  • Acara
  • Podcast
  • Blog
  • Pelanggan
  • Hukum • Privasi
  • Keamanan
الْعَرَبيّة 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 adalah rangkaian aplikasi bisnis open source yang mencakup semua kebutuhan perusahaan Anda: CRM, eCommerce, akuntansi, inventaris, point of sale, manajemen project, dan seterusnya.

Mudah digunakan dan terintegrasi penuh pada saat yang sama adalah value proposition unik Odoo.

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