Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

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

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

Dynamic Form View for Repetitive Fields?

Subscriure's

Get notified when there's activity on this post

This question has been flagged
fleetv17
1 Respondre
378 Vistes
Avatar
Precious Shun

How do you people usually do dynamic form view for repetitive fields

Like i have a tyre management system and lets say at slot_1 has slot_1_brand, _size, _otd, _rtd, _condition, etc.

Do I have to do that for every single tyre statically if i specifically, SPECIFICALLY, want to show it in form view?

All the guides been telling me to just do usual one2many and show it in tree list. But I want it in form view, and it has to be able to have readonly and invisible conditioning plus buttons repeated for every single line of data of the tyre.slot model in form view

So please tell me how do I do this, thank you so much in advance for anyone answering 

0
Avatar
Descartar
Christoph Farnleitner

Do you mean to add an undefined number of fields in the form? Like slot_1_brand, slot_2_brand, slot_n_brand where n is to be determined by *something*? What is the outcome you are looking for and why exactly is a One2many field not suitable? Because a One2many field is supposed to exactly handle this scenario... Also, One2many lists in forms allow for readonly, invisible (and column_invisible) conditions as well. So far it sounds like really bad model design.

Avatar
Cybrosys Techno Solutions Pvt.Ltd
Best Answer

Hi,


In Odoo, when you have repetitive data like tyre slots, the recommended approach is to create a tyre.slot model and link it to your main model (e.g., vehicle) via a One2many field. Then, in the form view, you can display each tyre slot in a form view inside a notebook or a group.


Code:

from odoo import models, fields, api


class Vehicle(models.Model):

    _name = 'fleet.vehicle'

    _description = 'Vehicle'


    name = fields.Char(string="Vehicle Name")

    tyre_slot_ids = fields.One2many('tyre.slot', 'vehicle_id', string="Tyre Slots")



class TyreSlot(models.Model):

    _name = 'tyre.slot'

    _description = 'Tyre Slot'


    vehicle_id = fields.Many2one('fleet.vehicle', string="Vehicle")

    slot_number = fields.Integer(string="Slot Number")

    brand = fields.Char(string="Brand")

    size = fields.Char(string="Size")

    otd = fields.Float(string="OTD")

    rtd = fields.Float(string="RTD")

    condition = fields.Selection([('new', 'New'), ('used', 'Used'), ('bad', 'Bad')], string="Condition")


    def button_repair(self):

        # Example button logic

        self.condition = 'new'


XML:

<record id="view_vehicle_form" model="ir.ui.view">

    <field name="name">fleet.vehicle.form</field>

    <field name="model">fleet.vehicle</field>

    <field name="arch" type="xml">

        <form string="Vehicle">

            <sheet>

                <group>

                    <field name="name"/>

                </group>

                <notebook>

                    <page string="Tyre Slots">

                        <field name="tyre_slot_ids">

                            <form>

                                <group>

                                    <field name="slot_number"/>

                                    <field name="brand"/>

                                    <field name="size"/>

                                    <field name="otd"/>

                                    <field name="rtd"/>

                                    <field name="condition" attrs="{'readonly':[('condition','=','bad')]}"/>

                                </group>

                                <footer>

                                    <button name="button_repair" type="object" string="Repair" class="btn-primary"/>

                                </footer>

                            </form>

                        </field>

                    </page>

                </notebook>

            </sheet>

        </form>

    </field>

</record>


Hope it helps

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

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

Registrar-se
Related Posts Respostes Vistes Activitat
Ya es posible hacer Upgrade de v17 a v17.1 ?
v17
Avatar
Avatar
1
d’oct. 25
1311
fleet management offline
fleet
Avatar
Avatar
Avatar
2
d’oct. 25
628
How to add a new Many2one field in res.config.settings? Solved
v17
Avatar
Avatar
Avatar
Avatar
4
d’oct. 25
3702
Add field to ALL models in Odoo
v17
Avatar
Avatar
Avatar
2
de set. 25
2373
How to disable Email notification - You have been assigned to Solved
v17
Avatar
Avatar
Avatar
Avatar
4
de set. 25
7770
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة 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 és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

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