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

Inheriting notebook Tree View

Subscriure's

Get notified when there's activity on this post

This question has been flagged
viewinheritancenotebook
2 Respostes
6534 Vistes
Avatar
nickchacha@gmail.com

Am seeking for your assistance on a slight challenge in view inheritance

There's a tree-view inside a notebook and that would like to add more fields to.

I have already inherited the main-view as shown below but i can't seem to get the new fields on the mentioned tree-view. 


Here's what i have so far and has failed. 
Disclaimer:  Am newbie so go 'hard' on me

        
            <field name="inherit_id" ref="stock.view_picking_form"/>
<field name="arch" type="xml">
<!-- <xpath expr="//notebook/page[2]/tree/field[@name='lot_id']" position="after">-->
<!-- <field name="gross_weight"/>-->
<!-- <field name="tare_weight"/>-->
<!-- <field name="moisture_cont" />-->
<!-- </xpath>-->

<notebook position="inside">
<page string="Detailed Operations" attrs="{'invisible': ['|', ('show_operations', '=', False), ('show_reserved', '=', False)]}">

<xpath expr="page[2]" position="inside">
<field name="move_ids_without_package" position="after">
<xpath expr="//tree/field[@name='lot_id']" position="after">
<field name="gross_weight"/>
<field name="tare_weight"/>
<field name="moisture_cont" />
</xpath>

</field>

</xpath>
</page>

</notebook>
</field>
        
0
Avatar
Descartar
Avatar
nickchacha@gmail.com
Autor Best Answer

After implementing @jack suggestion, i  have an error which. The view can no-longer find the already defined model fields. 

Below is the error.

Note: I have a model file which is inheriting the same model as the view and the 'missing' field is already defined there. 

Advanced apologies if am asking the obvious but apparently, i can't seem to figure this one out

Thanks

 <?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>

<record id="picking_orders_additions" model="ir.ui.view">
<field name="name">liroi_fields.picking_orders_additions</field>
<field name="model">stock.picking</field>
<field name="inherit_id" ref="stock.view_picking_form"/>
<field name="arch" type="xml">


<xpath expr="//field[@name='move_ids_without_package']/tree[1]" position="inside">
<field name="gross_weight"/>

</xpath>

</field>


</record>

</data>
</odoo>



# -*- coding: utf-8 -*-

from odoo import models, fields


class PickingOrdersFields(models.Model):
_inherit = 'stock.picking'

gross_weight = fields.Float(
string='Gross Weight',
# related='delivery_id.weight',
)
tare_weight = fields.Float(
string='Tare Weight',
# related='delivery_id.weight',
)
moisture_cont = fields.Float(
string='Moisture Content',
# related='delivery_id.weight',
)
0
Avatar
Descartar
Jack Dane

Hello,

Just to check is the "gross weight" field defiantly a field which is located in the model "lot_id"?

Could you share the Python code which extends the model?

Thanks,

Jack Dane

Another good way to check if the field exists is to go to settings->technical->models and search for the lot_id model. From here you will see all the fields in this model.

nickchacha@gmail.com
Autor

Hi Jack,

Please see the edited content for both the view and corresponding .py file

Thanks alot

Avatar
Jack Dane
Best Answer

Hello,

There are quite a few things wrong here, but I will try and help you best I can. Your first attempt (commented) looks promising. We all start somewhere.

Below is an example where you would have a One2many with a student model and you would like to add the last_name field to the tree view (it only has the first_name defined so far). 

If the form view is displayed as something like:

<field name="student_id"> 
    <tree>
        <field name="first_name"/>
    </tree>
</field>

You would inheirt the view like you have done and then add the field using the xpath. The expression would be:

<xpath expr="//field[@name='student_id']/tree[1]" position="inside">
    <field name="last_name"/>
</xpath>

This has added the field last_name from the Student model into the One2many.

I hope this helps if you need anything clarifying feel free to email/comment.

BTW I believe the notepad doesn't really matter as long as you start with //field_name

Thanks, 

0
Avatar
Descartar
nickchacha@gmail.com
Autor

Thanks a batch @jack. Let me try and revert

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
View inheritance Solved
view inheritance
Avatar
Avatar
1
de març 20
4529
How do I remove fields from a view in a custom module? Solved
view inheritance
Avatar
Avatar
Avatar
Avatar
12
de des. 18
36425
Weird error "Expression cannot be located in parent view" in view inheritance Solved
view inheritance
Avatar
Avatar
1
de jul. 16
8073
Two-level view inheritance, what am I missing?
view inheritance
Avatar
Avatar
2
de març 15
6993
view inheritance in openerp
view inheritance
Avatar
Avatar
1
de març 15
4430
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