تخطي للذهاب إلى المحتوى
أودو القائمة
  • تسجيل الدخول
  • جرب مجاناً
  • التطبيقات
    المالية
    • المحاسبة
    • فوترة
    • النفقات
    • جدول البيانات (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
حول هذا المنتدى
المساعدة

Python: Retrieving filtered records

اشتراك

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

لقد تم الإبلاغ عن هذا السؤال
filterpythonv18
3 الردود
1978 أدوات العرض
الصورة الرمزية
Tessa Roberts

Hello,


Is there a way to retrieve, in python, the domain of active filters in the list view or the list of record IDs displayed in the list view?


I have a search function on a custom field and in this function, I would like to call a function on the IDs of the list of records displayed in the list view.


I've tried looking in the context but there's no parameter similar to “active_ids”.


Is this possible?


Thank you

0
الصورة الرمزية
إهمال
Christoph Farnleitner

First, great you took the time to updated your post with your findings! Apart from that, I'm unsure about your usecase. For doing something based on records visible I would usually rather consider a computed field that is not stored. Also, as said, unsure about your usecase, but search, read, read_group etc all are functions on odoo.models (like create, write, etc) and can be extended per model. The search function for example has this definition: def search(self, domain, offset=0, limit=None, order=None) -> Self

الصورة الرمزية
Tessa Roberts
الكاتب أفضل إجابة

I've found a way to get the active domain.

However, I think there must still be a better way to solve the problem.


In the browser inspector, I studied the http requests sent and received when a filter was activated.

The request looks something like this:

{
"jsonrpc":"2.0",
"method":"call",
"params":{
"model":"crm.lead",
"domain":[["type","=","opportunity"],["date",">=","2019-04-18"]],
"fields":["partner_id","user_id","phone","categs_id","state",],
"limit":80,
"sort":"create_date DESC",
"context":{
"lang":"fr_FR",
"tz":"Europe/Paris",
"uid":31,
"allowed_company_ids":[1],
"params":{"action":1647,"model":"crm.lead","view_type":"list","cids":"","menu_id":451},
"stage_type":"opportunity",
"default_type":"opportunity",
"default_user_id":31,
"needaction_menu_ref":"sale.menu_sale_quotations",
"bin_size":true
}
},"id":393865456
}


I was able to recover the active domain by importing “request” from odoo.http


from odoo.http import request


And then, in the source code of my python function :


http_request_domain = request.params.get('domain')


Based on all this, I think I'll be able to retrieve the list of record ids corresponding to the domain and achieve my goal.


Have a nice day

1
الصورة الرمزية
إهمال
الصورة الرمزية
Cybrosys Techno Solutions Pvt.Ltd
أفضل إجابة

Hi,


In Odoo 17, you can retrieve the active filters (domain) in a list view and also access the records currently visible using the following method.

from odoo import models, api

class YourModel(models.Model):

    _inherit = 'your.model'


    @api.model

    def web_search_read(self, domain, fields, offset=0, limit=None, order=None, count_limit=None):

        # Domain contains the active filters in the list view

        print("Active domain (filters):", domain)

        # Fetch records visible in the list view

        records = self.search_read(domain, fields, offset=offset, limit=limit, order=order)

        print("Visible records:", records)

        # Proceed with the original behavior

        return super().web_search_read(domain, fields, offset=offset, limit=limit, order=order, count_limit=count_limit)


Hope it helps

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

Hey there!

I totally get what you're trying to do - this is actually a pretty common challenge in Odoo development. You want to grab either the current domain filters or the list of record IDs that are showing in your list view from within a custom search function. The tricky part is that when you're inside a search method, you're kind of "in the middle" of the search process, so the usual active_ids approach doesn't work here.


If you can control when your search function gets called, you can pass the domain through the context:

python

# In your custom search method
def _search_your_field(self, operator, value):
    context = self.env.context
    current_domain = context.get('search_default_domain', [])
    
    # Now you can work with the current domain
    # and call your function with the relevant IDs
    if current_domain:
        filtered_records = self.search(current_domain)
        your_custom_function(filtered_records.ids)
    
    # Return your search domain
    return [('your_field', operator, value)]

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

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

تسجيل
المنشورات ذات الصلة الردود أدوات العرض النشاط
Filters with multiple conditions
filter python deliveryorder
الصورة الرمزية
0
نوفمبر 24
1942
How i can apply filter into record ?
filter python orm
الصورة الرمزية
الصورة الرمزية
1
سبتمبر 19
2924
[✅ SOLVED] How to make sure odoo.addons.base.models.ir_cron will log the number of processed records on a cronjob completion ?
python cronjob entreprise v18
الصورة الرمزية
0
يوليو 25
1544
Problem with date filter BETWEEN two dates
filter date between v18
الصورة الرمزية
الصورة الرمزية
الصورة الرمزية
2
مايو 25
1968
[✅ SOLVED] How to extend a XML search filter view and add an additional filter ? تم الحل
filter searchview xmlview v18
الصورة الرمزية
الصورة الرمزية
1
مايو 25
3503
المجتمع
  • دروس
  • التوثيق
  • المنتدى
مصدر مفتوح
  • تحميل
  • جيت هاب "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