Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

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

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

Limit selections between two fields using Studio

Subscribe

Get notified when there's activity on this post

This question has been flagged
4 Replies
1091 Views
Avatar
Brandon Lackey

I'm trying to limit options shown in the Packages window.  I have two Many2One fields:

  • Carrier
  • Package Type

When I select a certain "Carrier" I only want to see the package types associated with that carrier.  For example "dhl" has (pack1, pack2, pack3), "fedex" has (pack4, pack5, pack6) and "usps" has (pack7, pack8, pack9).


I have figured out how to do this with a single carrier in the Domain of the "Package Type" field:

[["package_carrier_type","=","dhl"]]

However, I haven't figured out how to properly write the domain to work with all the carrier options.  Any help is greatly appreciated.

V16

0
Avatar
Discard
Avatar
Bob The Cow
Best Answer

Use this domain: [ '|',('carrier_id', '=', selected_carrier_id), ('carrier_id', '=', False)]

0
Avatar
Discard
Brandon Lackey
Author

Thank you for the input. Unfortunately, 'carrier_id' does not appear to be a valid domain entry in the Package Type field. Copying this code results in an "Domain not properly formed" error and I cannot find the 'carrier_id' when trying to add this manually in Studio with the Domain GUI.

Avatar
Cybrosys Techno Solutions Pvt.Ltd
Best Answer

Hi Brandon,

To achieve dynamic filtering of the "Package Type" field based on the selected "Carrier" in Odoo v16, you can use a computed domain in your model definition. Here's how you can set it up:

Ensure that the Carrier model has a relational field in the Package Type model and apply a domain for the package_type Many2one field using Studio.

You can define the domain directly in the Studio interface like this:

[('carrier_id', '=', carrier_id)]

This domain will filter the available options in the "Package Type" field based on the selected "Carrier"


Hope it helps

0
Avatar
Discard
Brandon Lackey
Author

Thank you for the input! I haven't been able to get this to work yet, but I don't think I fully understand how to "Ensure that the Carrier model has a relational field in the Package Type model", could you provide a bit more detail on hot to accomplish this?

Avatar
Brandon Lackey
Author Best Answer

I have still been unable to get this to work.  Any help is greatly appreciated.

0
Avatar
Discard
Avatar
Master
Best Answer

Hi,

I'd be glad to help you with limiting package type options based on the selected carrier in Odoo V16. Here's the domain you can use for the "Package Type" field:

[ '|',('carrier_id', '=', selected_carrier_id), ('carrier_id', '=', False)]


Explanation:

  • [('carrier_id', '=', selected_carrier_id)]: This part filters the "Package Type" records where the carrier_id field is equal to the currently selected carrier's ID (selected_carrier_id). This ensures only package types associated with the chosen carrier are shown.
  • '|' (OR operator): This separates the two conditions within the domain.
  • ('carrier_id', '=', False)]: This part allows you to see package types that are not associated with any carrier (if applicable in your data model). This provides flexibility if you have some generic package types that can be used with any carrier.

Hope help you. ​

0
Avatar
Discard
Brandon Lackey
Author

Thanks for the info and explanation. Unfortunately, this doesn't seem to be working, I get the following error:
Unknown field "stock.package.type.carrier_id" in domain of <field name="package_type_id"> ([["carrier_id","=","selected_carrier_id"]]))

The "carrier_id" field appears to be a list of the Shipping Methods, but the fields available while creating the domain under the "package_carrier_type" are the base carriers selected as the "Provider" (delivery_type) within the Shipping method. I've tried using this modified code, but it's not working either (doesn't error, but the selection field stays empty):
[["package_carrier_type","=","selected_delivery_type"]]

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
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة 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 is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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