تخطي للذهاب إلى المحتوى
أودو القائمة
  • تسجيل الدخول
  • جرب مجاناً
  • التطبيقات
    المالية
    • المحاسبة
    • فوترة
    • النفقات
    • جدول البيانات (BI)
    • المستندات
    • توقيع إلكتروني
    المبيعات
    • إدارة علاقات العملاء
    • المبيعات
    • نقطة البيع للمتاجر
    • نقطة البيع للمطاعم
    • الاشتراكات
    • تأجير
    المواقع الإلكترونية
    • أداة بناء المواقع الإلكترونية
    • متاجر إلكترونية
    • مدونة
    • المنتدى
    • دردشة مباشرة
    • التعليم الإلكتروني
    سلسلة التوريد
    • المستودعات
    • التصنيع
    • إدارة دورة حياة المنتج
    • المشتريات
    • الصيانة
    • الجودة
    الموارد البشرية
    • موظفون
    • التوظيف
    • إجازة عمل
    • التقييمات
    • الإحالات
    • تطبيق الأسطول
    التسويق
    • التسويق الإجتماعي
    • التسويق عبر البريد الإلكتروني
    • التسويق عبر الرسائل النصية
    • فعاليات
    • أتمتة التسويق
    • الاستطلاعات
    الخدمات
    • المشاريع
    • الجداول الزمنية
    • الخدمة الميدانية
    • مكتب المساعدة
    • التخطيط
    • مواعيد
    اﻹنتاجية
    • مناقشة
    • الموافقات
    • إنترنت الأشياء "IoT"
    • بروتوكول ربط المحادثات الصوتية عبر الإنترنت
    • المعرفة
    • WhatsApp
    التطبيقات الخارجية ستوديو أودو منصة أودو السحابية
  • قطاعات الأعمال
    البيع بالتجزئة
    • متجر كتب
    • متجر ملابس
    • متجر أثاث
    • متجر بقالة
    • متجر معدات
    • متجر ألعاب
    الطعام والضيافة
    • بار وحانة
    • المطعم
    • مطعم للوجبات السريعة
    • نزل للضيوف
    • موزّع مشروبات
    • فندق
    العقارات
    • وكالة عقارات
    • شركة هندسة معمارية
    • البناء
    • إدارة العقارات
    • العناية بالحدائق
    • اتحاد مُلاّك العقارات
    استشارة
    • مؤسسة محاسبية
    • شريك أودو
    • وكالة تسويقية
    • منشأة قانونية
    • استقطاب المواهب
    • التدقيق والتوثيق
    التصنيع
    • الأقمشة
    • معدني
    • الأثاث
    • الطعام
    • مصنع خمور
    • هدايا الشركات
    الصحة واللياقة البدنية
    • نادي رياضي
    • متجر نظارات
    • مركز لياقة بدنية
    • الممارسون الصحيون
    • صيدلية
    • صالون تصفيف الشعر
    التجارة
    • عامل صيانة
    • الأجهزة والمعدات التقنية ودعمها
    • أنظمة الطاقة الشمسية
    • صانع أحذية
    • خدمات التنظيف
    • خدمات التكييف (HVAC)
    غير ذلك
    • منظمة غير ربحية
    • وكالة بيئية
    • تأجير لوحات إعلانية
    • تصوير
    • تأجير دراجات
    • بائع وسيط للبرمجيات
    تصفح كافة قطاعات الأعمال
  • مجتمع أودو
    تعلم
    • دروس
    • التوثيق
    • شهادات
    • التدريب
    • مدونة
    • بودكاست
    قم بتعزيز التعليم
    • برنامج تعليم
    • Scale UP! لعبة الأعمال
    • قم بزيارة أودو
    احصل على البرنامج
    • تحميل
    • قارنْ الإصدارات
    • إطلاق
    تعاون
    • جيت هاب "Github"
    • المنتدى
    • فعاليات
    • الترجمات
    • كنْ شريكاً
    • خدمات الشركاء
    • سجل مكتب المحاسبة الخاص بك
    احصل على الخدمات
    • اعثر على شريك
    • اعثر على محاسب
    • قابل أحد مرشدي الأعمال
    • خدمات التنفيذ
    • مراجع العملاء
    • الدعم
    • الترقيات
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    الحصول على عرض توضيحي
  • الأسعار
  • المساعدة

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

  • إدارة علاقات العملاء
  • e-Commerce
  • المحاسبة
  • المخزون
  • PoS
  • المشروع
  • MRP
All apps
يجب أن تكون مسجلاً حتى تتفاعل مع المجتمع.
كافة المنشورات الأفراد الشارات
علامات التصنيف (عرض الكل)
odoo accounting v14 pos v15
حول هذا المنتدى
يجب أن تكون مسجلاً حتى تتفاعل مع المجتمع.
كافة المنشورات الأفراد الشارات
علامات التصنيف (عرض الكل)
odoo accounting v14 pos v15
حول هذا المنتدى
المساعدة

Tracking One2many fields of a model

اشتراك

تسلم الإشعارات عندما يكون هناك نشاط في هذا المنشور

لقد تم الإبلاغ عن هذا السؤال
trackingchatterv18CommunityEditionrelational fields
1 الرد
1747 أدوات العرض
الصورة الرمزية
Shreya Doodipala

I want to track changes in records of my One2many fields. I've tried the following code:

@api.model_create_multi

    def create(self, vals_list):

        records = super().create(vals_list)

        for record in records:

            if record.lead_id:

                message = f"New Secondary Salesman Added: {record.name}"

                record.lead_id.message_post(body=message, **{'body_is_html': True})

        return records


    def write(self, vals):

        # Store original values before the write operation

        old_values = {}

        for field_name, value in vals.items():

            if field_name in self._fields and self._fields[field_name].tracking:

                # For basic fields (Char, Float, Integer, etc.), directly store the old value

                # For Many2one, you might want to store the display_name or ID

                if self._fields[field_name].relational:

                    old_values[field_name] = self[field_name].display_name if self[field_name] else False

                else:

                    old_values[field_name] = self[field_name]



        res = super().write(vals)


        for record in self:

            if record.lead_id:

                body_message = f"<b>Changes to Secondary Salesman info '{record.display_name}':</b><br/>"

                has_changes = False

                for field_name, new_value in vals.items():

                    if field_name in record._fields and record._fields[field_name].tracking:

                        old_value = old_values.get(field_name)

                        current_value = record[field_name]


                        # Handle different field types for comparison and display

                        if record._fields[field_name].relational:

                            current_display_value = current_value.display_name if current_value else False

                            if str(old_value) != str(current_display_value): Compare display names or IDs

                                has_changes = True

                                field_description = record._fields[field_name].string

                                body_message += f"<li>{old_value or ''} to {current_display_value or ''} ({field_description})<br/>"

    #                     elif str(old_value) != str(current_value): # For non-relational fields

    #                         has_changes = True

    #                         field_description = record._fields[field_name].string

    #                         body_message += f"<li>{old_value or ''} to {current_value or ''} ({field_description}) <br/>"


    #             if has_changes:

    #                 record.lead_id.message_post(body=body_message, **{'body_is_html': True})

    #     return res

    # def unlink(self):

    #     for record in self:

    #         if record.lead_id:

    #             message = f"<b>Salesman Deleted:</b> {record.display_name}"

    #             record.lead_id.message_post(body=message, **{'body_is_html': True})

    #     return super().unlink()

While this works well for one model, when I add this to multiple models, I get the following error either while creating a new record or updating an existing one.

❌

UncaughtPromiseError > OwlError


Uncaught Promise > An error occured in the owl lifecycle (see this Error's "cause" property)


Occured on localhost:8069 on 2025-05-26 10:41:28 GMT


OwlError: An error occured in the owl lifecycle (see this Error's "cause" property)

    Error: An error occured in the owl lifecycle (see this Error's "cause" property)

        at handleError (http://localhost:8069/web/assets/f129831/web.assets_web.min.js:961:101)

        at App.handleError (http://localhost:8069/web/assets/f129831/web.assets_web.min.js:1608:29)

        at RootFiber.complete (http://localhost:8069/web/assets/f129831/web.assets_web.min.js:993:28)

        at Scheduler.processFiber (http://localhost:8069/web/assets/f129831/web.assets_web.min.js:1578:43)

        at Scheduler.processTasks (http://localhost:8069/web/assets/f129831/web.assets_web.min.js:1572:62)

        at http://localhost:8069/web/assets/f129831/web.assets_web.min.js:1569:67


Caused by: NotFoundError: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.

    at VMulti.patch (http://localhost:8069/web/assets/f129831/web.assets_web.min.js:796:116)

    at B.patch (http://localhost:8069/web/assets/f129831/web.assets_web.min.js:881:178)

    at VMulti.patch (http://localhost:8069/web/assets/f129831/web.assets_web.min.js:795:224)

    at VList.patch (http://localhost:8069/web/assets/f129831/web.assets_web.min.js:902:88)

    at B.patch (http://localhost:8069/web/assets/f129831/web.assets_web.min.js:881:178)

    at VToggler.patch (http://localhost:8069/web/assets/f129831/web.assets_web.min.js:721:78)

    at VList.patch (http://localhost:8069/web/assets/f129831/web.assets_web.min.js:902:88)

    at VMulti.patch (http://localhost:8069/web/assets/f129831/web.assets_web.min.js:795:224)

    at VMulti.patch (http://localhost:8069/web/assets/f129831/web.assets_web.min.js:795:224)

    at VToggler.patch (http://localhost:8069/web/assets/f129831/web.assets_web.min.js:721:78)

What is causing the error? OR 
How can I add tracking information to my form's chatter?


Odoo v18 Community edition

0
الصورة الرمزية
إهمال
الصورة الرمزية
D Enterprise
أفضل إجابة


This error is not actually caused by the Python backend logic itself (your create, write, unlink methods), but by how the frontend (Owl JS framework in Odoo) is attempting to render the result of the operation, especially if a view or widget is affected in a way it wasn't expecting.Add this at the top of your file:
from odoo.tools import html_escape

Then sanitize your HTML message in the write method:

Replace:

body_message += f"<li>{old_value or ''} to {current_display_value or ''} ({field_description})<br/>"

with:
body_message += f"<li>{html_escape(str(old_value) or '')} → {html_escape(str(current_display_value) or '')} ({html_escape(field_description)})</li>"



0
الصورة الرمزية
إهمال
هل أعجبك النقاش؟ لا تكن مستمعاً فقط. شاركنا!

أنشئ حساباً اليوم لتستمتع بالخصائص الحصرية، وتفاعل مع مجتمعنا الرائع!

تسجيل
المنشورات ذات الصلة الردود أدوات العرض النشاط
Is it possible to receive an email and log it to the chatter in contacts? تم الحل
email chatter v18
الصورة الرمزية
الصورة الرمزية
1
سبتمبر 25
1596
Modify Pivot View
Pivot v18 CommunityEdition
الصورة الرمزية
الصورة الرمزية
1
يونيو 25
1708
Unable to send email notifications through write
notifications v18 CommunityEdition
الصورة الرمزية
الصورة الرمزية
1
يونيو 25
1753
Track m2o field changes in chatter with link instead of text note? تم الحل
tracking sale.order chatter
الصورة الرمزية
الصورة الرمزية
1
أغسطس 21
4639
Hide Records based on user group only in a particular view
views record_rule v18 CommunityEdition
الصورة الرمزية
الصورة الرمزية
الصورة الرمزية
2
سبتمبر 25
1455
المجتمع
  • دروس
  • التوثيق
  • المنتدى
مصدر مفتوح
  • تحميل
  • جيت هاب "Github"
  • المشغل الآلي رنبوت
  • الترجمات
خدماتنا
  • استضافة أودو إس إتش
  • الدعم
  • الترقية
  • التطويرات المخصصة
  • التعليم
  • اعثر على محاسب
  • اعثر على شريك
  • كنْ شريكاً
معلومات عنا
  • شركتنا
  • أصول العلامة التجارية
  • اتصلْ بنا
  • الوظائف
  • فعاليات
  • بودكاست
  • مدونة
  • عملاء
  • قانوني • الخصوصية
  • الحماية
الْعَرَبيّة 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

أودو هو عبارة عن مجموعة من تطبيقات الأعمال مفتوحة المصدر التي تغطي جميع احتياجات شركتك، مثل: إدارة علاقات العملاء والتجارة الإلكترونية والمحاسبة والمخزون ونقاط البيع وإدارة المشاريع وما إلى ذلك.

ما يجعل من أودو مميزاً هو هدفه بأن يكون سهل الاستخدام للغاية ومتكاملاً تمامًا في الوقت ذاته.

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