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

How to limit the choice in radio button depending on other fields

Subscribe

Get notified when there's activity on this post

This question has been flagged
restaurantform_viewodooV8
1584 Views
Avatar
Sonny

I need to make the radio button option to only "container" when the values of direction='export', transport='ocean' and ocean_shipment_type='fcl'.

Here are the snippets of models involved:

class FreightShipment(models.Model): 
    _name = 'freight.shipment'

    direction = fields.Selection(([('import', 'Import'), ('export', 'Export')]), string='Direction' )
    transport = fields.Selection(([('air', 'Air'), ('ocean', 'Ocean'), ('land', 'Land')]),
                                 string='Transport Via')
    ocean_shipment_type = fields.Selection(([('fcl', 'Full Container(FCL)'),
                                             ('lcl', 'Less Container(LCL)')]),
                                           string='Ocean Shipment Type')
    freight_packages = fields.One2many( 'shipment.package.line', 'shipment_id')
class ShipmentPackageLine(models.Model): 
    _name = 'shipment.package.line'
    _rec_name = 'package'

     package_type = fields.Selection([('item', 'Loose Cargo'), ('container', 'Containerized')] ,
                                    string="Package Type", default='item')
     ...

Here is the XML view snippet:

<record model="ir.ui.view" id="freight_shipment_form_view"> 
   <field name="name">freight.shipment.form.view</field>
   <field name="model">freight.shipment</field >
   ...
   <sheet>
      ...
      <div class="oe_title mb24">
         <h1>
            <field class="text-break" name="name" default_focus="1" readonly="1"/>
         </ h1>
         <h3>
            <field name="direction" widget="radio" required="1" options="{'horizontal': true}"/>
         </h3>
      </div>
      ...
      <group string="Transport Details">
         <field name="is_transport_read_only" invisible="1" />
         <group>
            <field name="transport" widget="radio" options="{'horizontal': true}" required="1" readonly="is_transport_read_only"/>
         </group>
         <group>
            <field name ="ocean_shipment_type" invisible="shipment != 'ocean'" required="shipment == 'ocean'"/>
            <field name="inland_shipment_type" invisible="transport != 'land'" required="transport == 'land'"/>
         </group>
      </group>
      ...
      <notebook>
         ...
        <page string="Package Details" invisible="direction != 'export'">
           <field name="freight_packages" nolabel="1" widget="one2many_list">
              <tree string="Package">
                 <field name="name" required="1 "/>
                 ...
              </tree>
              <form string="Package">
                 <group>
                    <label for="package_type"/>
                    <div>
                       <field name="package_type" widget="radio" options="{'horizontal':True}"/>
                    </div>
                 </group>
                 <group invisible="package_type != 'container'">
                    <group string="Containerized">
                       <field name="name" required="1"/>
                    </group>
                    ...
                 <group invisible="package_type != 'item'">
                    <group string="Loose Cargo">
                       <field name="name" required="1"/>
                    </group>
                 ...


Here is the solution Microsoft pilot recommended but this not worked.

# Package type options 
@api.onchange('direction', 'transport', 'ocean_shipment_type')
def _onchange_shipment_conditions(self):
   for package in self.freight_packages:
      if self.direction == 'export' and self.transport == ' ocean' and self.ocean_shipment_type == 'fcl':
         package.package_type = 'container'
         package.fields_get()['package_type']['selection'] = [('container', 'Containerized')]
      else:
         package.fields_get()['package_type']['selection'] = [('item', 'Loose Cargo'), ('container', 'Containerized')]


How to fix my issue?



0
Avatar
Discard
OdooBot

Sehr geehrte Damen und Herren,

 

ich bin bis einschließlich 03.01.2025 nicht im Büro. Eingehende E-Mails werden nicht zeitnah bearbeitet oder weitergeleitet.

 

Für dringende allgemeine Anfragen bitte ich Sie unsere Info-E-Mail-Adresse zu verwenden (info@be4energ.com).

 

Für Angebotsanfrage oder Fragen zu Projekten oder Planungen ist unser Projektierungsteam (projects@be4energy.com) für Sie erreichbar.

 

Mit herzlichem Gruße

 

Stefan Galler

 

 

Dear Sir or Madam,

 

I will be out of the office until January 3rd, 2025. Incoming emails will not be processed or forwarded promptly.

 

For urgent general inquiries, please use our general email address (info@be4energ.com).

 

For requests for quotations or questions regarding projects or planning, our project planning team (projects@be4energy.com) is available to assist you.

 

With kind regards,

 

Stefan Galler

 

 

 

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
can't find table planner in Odoo8 POS for restuarant
pos restaurant odooV8
Avatar
Avatar
1
Apr 16
3300
Hide or remove button added by xpath Solved
xpath inherited form_view odooV8
Avatar
Avatar
Avatar
Avatar
8
Oct 22
33106
How do I filter selection from form view?
filtering form_view res.users odooV8
Avatar
Avatar
1
May 16
7870
Orders on a kitchen screen?
restaurant
Avatar
Avatar
Avatar
Avatar
Avatar
5
Jul 25
9926
CONFIGURACION DE CORREO PROPIO POR PRUMERA VEZ
odooV8
Avatar
0
Mar 25
2000
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