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
    Real Estate
    • Real Estate Agency
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consulting
    • Accounting Firm
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Furnitures
    • Food
    • 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
    • Solar Energy Systems
    • Shoe Maker
    • Serveis de neteja
    • HVAC Services
    Others
    • 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

Odoo 18 - Custom Module - Error on nested class view

Subscriure's

Get notified when there's activity on this post

This question has been flagged
developmentmodules
2 Respostes
3612 Vistes
Avatar
Cedric

Hey all, writing some Odoo modules to get into module development.

I have a wizard.py​ that specifies:

class MyWizard(models.TransientModel):
    _name = 'my.wizard'
    _description = 'Wizard'
    line_ids = fields.One2many("my.wizard.line", "wizard_id", string="Lines")


And a wizard_line.py​that has:

class MyWizardLine(models.TransientModel):
    _name = 'my.wizard.line'
    _description = 'Wizard Line'
    wizard_id = fields.Many2one('my.wizard', string="Wizard")
    sale_line_id = fields.Many2one('sale.order.line', string="Sale Order Line")
    product_id = fields.Many2one('product.product', string="Product", required=True)

Both are being imported in __init__.py​:

from . import wizard
from . import wizard_line


I have a view under views/wizard_view.xml​:

<odoo>
    <record id="my_wizard_form" model="ir.ui.view">
        <field name="name">my.wizard.form</field>
        <field name="model">my.wizard</field>
        <field name="arch" type="xml">
            <form string="This is a wizard">
                <group>
                    <field name="sale_id" readonly="1"/>
                    <field name="line_ids">
                        <tree>
                            <field name="product_id"/>
                        </tree>
                    </field>
                </group>
                <footer>
                    <button string="Cancel" class="btn-secondary" special="cancel"/>
                </footer>
            </form>
        </field>
    </record>
</odoo>


But this part:

<field name="line_ids">
​<tree>
    ​<field name="product_id"/>
​</tree>
</field>


Throws an error saying:

Field "product_id" does not exist in model "my.wizard"

It appears as if the view is trying to access product_id​ directly on my.wizard​ while it should grab the one that's available through the line_ids​ One2many reference to my.wizard.line​?


Am I doing this wrong?

0
Avatar
Descartar
Cedric
Autor

It does, doesn't it...

However, line_ids is defined as follows in the parent class with name my.wizard​:

line_ids = fields.One2many("my.wizard.line", "wizard_id", string="Lines")

The line model has the name:

_name = 'my.wizard.line'

The view references the parent model:

<field name="model">my.wizard</field>

And subsequently uses line_ids​ correctly:

<field name="line_ids">

I feel like I'm making some obvious logic error here somewhere...

Caitlyn Beasley

It looks like the error might be related to how the nested class is being referenced in the view. Double-check that the correct model name is used in the record or field tags within the XML. Also, make sure any custom fields in the nested class are properly defined and accessible.

Cedric
Autor

Hi Emad,

Thank you so much! I knew it HAD to be some new tag in Odoo 18 :-)

I can't accept or upvote because I don't have the karma to do so yet. But when I get my 5 karma, I'll revisit, accept and upvote :-)

Avatar
Emad Akram
Best Answer

Hello Cedric

in Odoo 18 the tag 

<tree> 

was replaced with the tag 

<list>

So in your current code Odoo handles the product_id field as if its a field in the model "my.wizard"

if you use the <list> instead of the <tree> it will handle it as a field in the "my.wizard.line"

If this helps please upvote my answer and mark it correct

0
Avatar
Descartar
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Best Answer

Hi,

Please check with the following code.

<field name="line_ids">
<list name="Lines">
<field name="product_id"/>
</list>
</field>

In Odoo 18 tag <tree> replaced with the  <list>.


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
How to upgrade modules in a specific file?
development modules
Avatar
0
de març 24
2454
Trying to add fields to sale order form view give "AssertionError: Element openerp has extra content" Solved
development modules
Avatar
Avatar
2
de nov. 16
6571
Error: External ID not found in the system Solved
development modules
Avatar
Avatar
Avatar
3
de febr. 16
17439
How do I apply changes to and test the TDD Developer Workflow ? Solved
development modules
Avatar
Avatar
1
de març 15
5089
How to prevent some modules from loading
development modules
Avatar
Avatar
Avatar
Avatar
3
de març 15
10333
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