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

Need help with domain in Many2one field

اشتراك

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

لقد تم الإبلاغ عن هذا السؤال
domainpyhtonv17
3 الردود
7870 أدوات العرض
الصورة الرمزية
IRIG Events

Hello,


I am struggling a bit with something and I am hoping that somebody here with a lot more experience can help me. 


I am creating a module where I have a few models, the relevant ones are: 

  • event
  • venue
  • hall
  • stand

This module is to manage stands in tradeshows, so an event can have a lot of stands, but only one venue, and a venue can have many halls and each hall can have many stands. 

At the moment it works, I am using Many2one fields to link everything up and it works. However, when I create a stand, I want to filter the options of the hall where the stand will be, to display only the available halls of the venue where the parent event is happening. 

I have been trying to accomplish that filter by using this in the stand model:

  ​event_id = fields.Many2one('dev.event', string='Event')
hall_id = fields.Many2one('dev.hall', string='Hall',
​ ​ ​ ​ ​ ​ ​domain="[('venue_id','=','event_id.venue_id')]")

Although the code doesnt throw an error, it also doesnt show any results.


I also tried taking the aproach of using a function for the domain... but that fell beyond my current experience, so I couldnt make it work.


Any help will be greatly appreciated.



1
الصورة الرمزية
إهمال
الصورة الرمزية
IRIG Events
الكاتب أفضل إجابة

Hello


Mily Shajan


Thank you very much for the links. I followed the video, but when I got to download the web_domain_field module, it says it is deprecated, therefore I will leave it as a last resort.


Cybrosys


Thank you for the snippet. unfortuanately for some reason the domain does not get applied on return. I added a sneaky print() statement to verify that the function was firing and it is, but the domain remains unchanged in the field. 


Also, the isue of using the on_change hook is that it will only fire when the field is actually changed, so when I edit the record without changing the event it will display the unfiltered options. I have figured that if I create another field to display the name of the venue from a computed field, the function will fire when event is modified and also when the record is loaded. However, although the function does fire, the domain still doesnt get applied on return. Could it have some sort of typo or something?


@api.depends('event_id')

def compute_hall_ids(self):

        domain = []

        for rec in self:

            print(f'The venue Id of the event {rec.event_id.name} is: {rec.event_id.venue_id.id}')

            rec.venue_name = rec.event_id.venue_id.name

            domain = [('venue_id.id', '=', rec.event_id.venue_id.id)]

        print(domain)

        return {'domain': {'hall_id': domain}}


The printout I get for the domain is  [('venue_id', '=', 7)] as an example



cheers!


FINAL SOLUTION:

After reading the documentation more in depth, I found out that the @api.onchange and @api.depends decorators, will not fire the return statement, so that is why it wasnt being applied. 

Using the web_domain_field module did the trick for me. Even on V17. 

Cheers!



1
الصورة الرمزية
إهمال
Nicolás

Hi!
I am dealing with the same issue, working with odoo 17.

So to summarize, the only way you could solve it was by intslaling the Web Domain Field module? (https://apps.odoo.com/apps/modules/12.0/web_domain_field)

Thank you,
Nicolás

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

Hi,

You can solve the issue by applying the domain dynamically.

    


@api.onchange('event_id')

def _onchange_event_id(self):

   if self.event_id:

       domain = [('venue_id', '=', self.event_id.venue_id.id)]

   else:

       domain = []

   return {'domain': {'hall_id': domain}}


You can also refer to How to Apply Dynamic Domain for Relational Fields in 


Hope it helps

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

Hi 

Create a dynamic domain for the field. Check this reference to set a dynamic domain for the field

Dynamic Domain for a field

Domain for Relational Fields in Odoo


Regards

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

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

تسجيل
المنشورات ذات الصلة الردود أدوات العرض النشاط
Connecting a Namecheap domain with the Odoo app hosted on an AWS EC2 instance
domain ec2 v17
الصورة الرمزية
الصورة الرمزية
2
فبراير 24
2824
Ya es posible hacer Upgrade de v17 a v17.1 ?
v17
الصورة الرمزية
الصورة الرمزية
1
أكتوبر 25
1213
How to add a new Many2one field in res.config.settings? تم الحل
v17
الصورة الرمزية
الصورة الرمزية
الصورة الرمزية
الصورة الرمزية
4
أكتوبر 25
3515
Add field to ALL models in Odoo
v17
الصورة الرمزية
الصورة الرمزية
الصورة الرمزية
2
سبتمبر 25
2222
How to disable Email notification - You have been assigned to تم الحل
v17
الصورة الرمزية
الصورة الرمزية
الصورة الرمزية
الصورة الرمزية
4
سبتمبر 25
7553
المجتمع
  • دروس
  • التوثيق
  • المنتدى
مصدر مفتوح
  • تحميل
  • جيت هاب "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