Skip to Content
Odoo मेन्यू
  • Sign in
  • मुफ़्त में आज़माएं
  • ऐप्लिकेशन
    फ़ाइनेंस
    • अकाउंटिंग
    • इनवॉइसिंग
    • एक्सपेंस
    • स्प्रेडशीट (बीआई)
    • डॉक्यूमेंट्स
    • साइन
    सेल्स
    • सीआरएम
    • सेल्स
    • पीओएस शॉप
    • पीओएस रेस्टोरेंट
    • सब्सक्रिप्शन
    • रेंटल
    वेबसाइट
    • वेबसाइट बिल्डर
    • ई-कॉमर्स
    • ब्लॉग
    • फ़ोरम
    • लाइव चैट
    • ई-लर्निंग
    सप्लाई चेन
    • इन्वेंट्री
    • मैन्युफ़ैक्चरिंग
    • पीएलएम
    • परचेज़
    • मेंटेनेंस
    • क्वालिटी
    मानव संसाधन
    • कर्मचारी
    • रिक्रूटमेंट
    • टाइम ऑफ़
    • अप्रेज़ल
    • रेफ़रल
    • फ़्लीट
    मार्केटिंग
    • सोशल मार्केटिंग
    • ईमेल मार्केटिंग
    • एसएमएस मार्केटिंग
    • इवेंट
    • मार्केटिंग ऑटोमेशन
    • सर्वे
    सेवाएं
    • प्रोजेक्ट
    • टाइमशीट
    • फ़ील्ड सर्विस
    • हेल्पडेस्क
    • प्लानिंग
    • अपॉइंटमेंट
    प्रॉडक्टिविटी
    • डिस्कस
    • अप्रूवल
    • आईओटी
    • वीओआईपी
    • नॉलेज
    • WhatsApp
    तीसरे पक्ष के ऐप्लिकेशन Odoo स्टूडियो Odoo क्लाउड प्लेटफ़ॉर्म
  • इंडस्ट्री
    रीटेल
    • बुक स्टोर
    • क्लोदिंग स्टोर
    • फ़र्नीचर स्टोर
    • ग्रॉसरी स्टोर
    • हार्डवेयर स्टोर
    • टॉय स्टोर
    Food & Hospitality
    • बार और पब
    • रेस्टोरेंट
    • फ़ास्ट फ़ूड
    • Guest House
    • बेवरिज डिस्ट्रीब्यूटर
    • होटल
    रियल एस्टेट
    • Real Estate Agency
    • आर्किटेक्चर फ़र्म
    • कंसट्रक्शन
    • एस्टेट मैनेजमेंट
    • गार्ड्निंग
    • प्रॉपर्टी ओनर असोसिएशन
    कंसल्टिंग
    • अकाउंटिंग फ़र्म
    • Odoo पार्टनर
    • मार्केटिंग एजेंसी
    • लॉ फ़र्म
    • टैलेंट ऐक्विज़िशन
    • ऑडिट & सर्टिफ़िकेशन
    मैन्युफ़ैक्चरिंग
    • टेक्सटाइल
    • Metal
    • फ़र्नीचर
    • फ़ूड
    • Brewery
    • कॉर्पोरेट गिफ़्ट
    हेल्थ & फिटनेस
    • स्पोर्ट्स क्लब
    • आईवियर स्टोर
    • फिटनेस सेंटर
    • वेलनेस प्रैक्टिशनर
    • फॉर्मेसी
    • हेयर सैलून
    Trades
    • Handyman
    • आईटी हॉर्डवेयर और सपोर्ट
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    अन्य
    • Nonprofit Organization
    • एन्वायरमेंटल एजेंसी
    • बिलबोर्ड रेंटल
    • फ़ोटोग्राफी
    • बाइक लीजिंग
    • सॉफ़्टवेयर रीसेलर
    Browse all Industries
  • कम्यूनिटी
    सीखें
    • ट्यूटोरियल्स
    • दस्तावेज़
    • सर्टिफ़िकेशन
    • ट्रेनिंग
    • ब्लॉग
    • पॉडकास्ट
    शिक्षा को बढ़ावा दें
    • एजुकेशन प्रोग्राम
    • स्केल अप! बिजनेस गेम
    • Odoo के ऑफ़िस में आएं
    सॉफ़्टवेयर पाएं
    • डाउनलोड
    • वर्शन की तुलना करें
    • रिलीज़
    साथ मिलकर काम करें
    • Github
    • फ़ोरम
    • इवेंट
    • अनुवाद
    • पार्टनर बनें
    • Services for Partners
    • अपना अकाउंटिंग फ़र्म रजिस्टर करें
    सेवाएं पाएं
    • पार्टनर ढूंढें
    • अकाउंटेंट खोजें
    • सलाहकार की मदद लें
    • इम्प्लिमेंटेशन सेवाएं
    • कस्टमर रेफ़रेंस
    • सहायता
    • अपग्रेड
    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
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
Help

Filter value 2 field of Many2one

Subscribe

Get notified when there's activity on this post

This question has been flagged
pythonpython2.7odooodoo10
5 Replies
6968 Views
Avatar
Fazryan Fareka Riznendi

Hello World :D

please help, I want to filter values ​​from fields that are in many2one.
I have tried various ways, but still have difficulties in understanding.

so this my code;

zona_parkir=fields.Char('Zona Parkir', related='location_id.zone_id.name', readonly='True')
location_id=fields.Many2one('parking_location', string='Lokasi', required='True')
 class ParkingLocation(models.Model): #parking_location
_name='parking_location'
_rec_name='name'

name=fields.Char('Lokasi')
zone_id=fields.Many2one('parking_zone', string='Zona')
class ParkingZone(models.Model):
_name='parking_zone' #parking zone
_rec_name='name'

name=fields.Char('Zona Parkir')    billing=fields.Float('Tarif')
information=fields.Text('Keterangan')
 parking_log_ids=fields.One2many('parking_log','parking_log_id',string='Log Parkir')class ParkingLog(models.Model):
_name='parking_log'
_rec_name='vehicle_id'
vehicle_id=fields.Many2one('vehicle',string='Nomor Kendaraan')
vehicle_type_id=fields.Char(string='Jenis Kendaraan', related='vehicle_id.vehicle_type.name', readonly='True')
rate_id=fields.Float('Tarif / Jam', related='vehicle_id.vehicle_type.billing')
user_id=fields.Many2one('res.users',string='Juru Parkir', default=lambda self: self.env.user, readonly='true')
parking_log_id=fields.Many2one('parking_session', string='Sesi Parkir', readonly='True')

    total_rate=fields.Float(string='Total Biaya Parkir',states={'in' : [('readonly', 'False')], 'paid' : [('readonly', 'False')]}, store='True', readonly='True', compute='action_close', track_visibility='onchange')
parking_point_id=fields.Many2one('parking_point',string='Titik Parkir')
parking_location_id=fields.Char('Lokasi Parkir', related='parking_log_id.location_id.name',readonly='True')
parking_zone_rate_id=fields.Char('Zona Parkir', related='parking_log_id.zona_parkir',readonly='True')
parking_hours=fields.Float('Lama Parkir', store='True', readonly='True', compute='action_close', track_visibility='onchange')


class Vehicle(models.Model): _name='vehicle' _rec_name='vehicle_number' vehicle_type=fields.Many2one('vehicle_type',string='Jenis Kendaraan',ondelete='cascade')
    vehicle_number=fields.Char(string='Nomor Kendaraan'
class VehicleType(models.Model): _name='vehicle_type'

    name=fields.Char('Jenis Kendaraan')
    billing=fields.Float('Tarif')

so the point is,  when I select ('location_id')

suppose I make 3 zones in that field,
zone X = B = 2 and C = 3
zone Y = B = 1.5 and C = 2.5
zone Z = B = 1 and C = 2

then the value I previously inputted has been recorded in the "billing" field and when I "add item" in the o2m field, the value in it is the filter result from the zone of one of the zones I selected

What do I think I should do?

maybe there is my code that is not supposed to exist / is not suitable.
also ask for advice :D


I will appreciate all forms of answers, thank you very much :-D

0
Avatar
Discard
Sehrish

try this: https://learnopenerp.blogspot.com/2020/09/domain-filter-many2one-field-odoo13.html

Avatar
Simplify-ERP® Developers
Best Answer

Hello, i understand what you need and here i am going to post a code block that i used to filter the products shown to a user on a sale order:

    def _get_products(self):
        ids = []
        res = {}
        for i in self.sale_order_id.order_line:
            ids.append(i.product_id.id)
        res.update({
                'domain': {
                    'call_product_id': [('id', 'in', ids)],

                }
            })

        return res
So here in the code block, only the products that were added on the original sale order, would get shown on my many2one field with name call_product_id to product.template for another model.

i hope that you can use this for your own good, remember to change the model and the field name too, mine is called call_product_id = fields.Many2one('product.template',string = 'Product')

Riste Kabranov

odoo developer at simplify-erp.com

0
Avatar
Discard
Fazryan Fareka Riznendi
Author

thank you for the response,

my code now ;

def _get_products(self):

ids = []

res = {}

for i in self.parking_zone_rate.name:

ids.append(i.rate_id.id)

res.update({

'domain': {

'parking_zone_rate_id': [('id', 'in', ids)],

}

})

return res

but still have difficulties in understanding :(

if i use domain like this code, can you help how?

Multiple Condition

Simple condition in programming:

if field1 = 5 or (field2 ! = 10 and field3 = 12)

In OpenERP domain filter, it will be written as:

domain = ['|',('field1','=',5),('&',('field2','!=',10),('field3','=','12'))]

thanks before :D

Avatar
Nikunj Dhameliya
Best Answer

Hi,

You can filter records by using domain in XML.

If this is not worked then try to send many2one I'd in context and use name_search method to filter record

0
Avatar
Discard
Fazryan Fareka Riznendi
Author

thankyou for the response,

can you tell me how?

or what code should I make?

Enjoying the discussion? Don't just read, join in!

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

Sign up
Related Posts Replies Views Activity
[SOLVED] How to Hide or Delete Trash Icon in One2many field Solved
python python2.7 odoo odoo10
Avatar
Avatar
2
अग॰ 25
12927
Filter field domain one2many to many2one Solved
python python2.7 odoo odoo10
Avatar
Avatar
1
दिस॰ 19
10343
[Solved] Inherit fields to existing tables Solved
python python2.7 odoo odoo10
Avatar
Avatar
Avatar
4
जन॰ 19
10305
How to calculate the value of results in one2many field
python python2.7 odoo odoo10
Avatar
Avatar
1
जन॰ 19
7126
Generate XLSX(Excel) report in odoo 10 from custom module?
python python2.7 odoo odoo10
Avatar
Avatar
Avatar
2
जुल॰ 18
15344
कम्यूनिटी
  • ट्यूटोरियल्स
  • दस्तावेज़
  • फ़ोरम
ओपन सोर्स
  • डाउनलोड
  • Github
  • रनबॉट
  • अनुवाद
सेवाएं
  • Odoo.sh Hosting
  • सहायता
  • अपग्रेड
  • कस्टम डेवलपमेंट्स
  • शिक्षा
  • अकाउंटेंट खोजें
  • पार्टनर ढूंढें
  • पार्टनर बनें
हमारे बारे में
  • हमारी कंपनी
  • ब्रांड ऐसेट
  • संपर्क करें
  • नौकरियां
  • इवेंट
  • पॉडकास्ट
  • ब्लॉग
  • ग्राहक
  • लीगल • गोपनीयता
  • सुरक्षा
الْعَرَبيّة 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, बिज़नेस से जुड़े ऐप्लिकेशन का एक कलेक्शन है जो ओपन सोर्स पर आधारित है. इसमें आपकी कंपनी की हर ज़रूरत के लिए ऐप्लिकेशन हैं. जैसे, सीआरएम, ई-कॉमर्स, अकाउंटिंग, इन्वेंट्री, पॉइंट ऑफ़ सेल, प्रोजेक्ट मैनेजमेंट वगैरह.

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