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

one2many field is not showing after created at new model

Subscriure's

Get notified when there's activity on this post

This question has been flagged
one2manyrelationfield
5407 Vistes
Avatar
Gamey Garcia Varela

Hello, I'm developing a module to take the control of a touristic transportation company what do is make an order service of tours for people taking the data from sale.order.lines (the previously sold tours) and with this info I take the vehicle and operator from Fleet module, and with all this data make the service page. 

The problem is after I saved the data I took from sale.order.lines, it saves the data at the table I created but the model don't show it at the view.

This is the code:

----PYTHON file:

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

# Part of Odoo. See LICENSE file for full copyright and licensing details.

from openerp import models, fields, api


class ServicesPage(models.Model):

_name = 'services.page'


name = fields.Char('Referencia Hojas Servicios', readonly=True)

fecha_tour = fields.Date('Fecha de Servicio')

page_lines_id = fields.One2many('page.lines', 'service_page_id', string='Líneas de Servicio',copy = True) 


@api.model

def create(self, vals):

vals['name'] = self.env['ir.sequence'].get('services.page')

return super(ServicesPage, self).create(vals)


@api.multi

def write(self, vals):      

result = super(ServicesPage, self).write(vals)

return result


class PageLines(models.Model):

_name = 'page.lines'


name = fields.Char('Referencia Línea de Hoja', readonly=True)

product_id = fields.Many2one('product.product', string = "Servicios")

camioneta = fields.Many2one('fleet.vehicle', string='Camioneta')

chofer = fields.Many2one('res.partner', string='Operador')

combustible = fields.Float('Combustible')

entradas = fields.Float('Entradas')

estacionamiento = fields.Float('Estacionamiento')

casetas = fields.Float('Casetas')

viaticos = fields.Float('Viáticos')

derecho_piso = fields.Float('Derecho Piso')

guia = fields.Float('Guía')

otros = fields.Float('Otros')

service_page_id = fields.Many2one('services.page', 'Service Page Reference',index=True, copy=False)


service_lines_ids = fields.One2many('services.lines', 'page_line_id', string='Líneas de Servicio', copy = True) 


@api.model

def create(self, vals):

vals['name'] = self.env['ir.sequence'].next_by_code('page.lines')    

return super(PageLines, self).create(vals)


@api.multi

def write(self, vals):        

result = super(PageLines, self).write(values)

return result


class ServicesLines(models.Model):

_name = 'services.lines'


name = fields.Char('Referencia Línea de Servicio',readonly=True)


page_line_id = fields.Many2one('page.lines', 'Page Reference',index=True, copy=False)

service_id = fields.Many2one('sale.order.line', string='Servicios Confirmados')

pax = fields.Integer('No. Personas')

pax_asignado = fields.Integer('Cantidad Personas Asignadas')


@api.model

def create(self, vals):

vals['name'] = self.env['ir.sequence'].next_by_code('services.lines')    

return super(ServicesLines, self).create(vals)


@api.multi

def write(self, vals):        

result = super(ServicesLines, self).write(values)

return result


----- XML FILE:


<openerp>

  <data>


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

            <field name="name">services.page.tree</field>

            <field name="model">services.page</field>

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

                <tree string="Hojas de Servicios">

                    <field name ="name"/>

                    <field name ="fecha_tour"/>

                </tree>

            </field>

    </record>



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

      <field name="name">view_form_create_service_page_ui</field>

      <field name="model">services.page</field>

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

         <form string="Hojas de Servicios">            

            <sheet>                

                <div class="oe_title">

                    <h1>

                        <field name="name" readonly="1"/>

                    </h1>

                </div>              

                <group>  

                    <field name="fecha_tour"/> 

                </group>

                <notebook>

                    <page string="Hojas de Servicios">

                        <field name="page_lines_id" mode="tree">

                            <form string="Líneas de Hojas de Servicios">

                                <group>

                                    <field name="product_id"/>                               

                                    <field name="chofer"/>

                                    <field name="camioneta"/>                                

                                    <field name="combustible"  widget="monetary"/>

                                    <field name="entradas"  widget="monetary"/>

                                    <field name="estacionamiento"  widget="monetary"/>

                                    <field name="casetas"  widget="monetary"/>

                                    <field name="viaticos"  widget="monetary"/>

                                    <field name="derecho_piso"  widget="monetary"/>

                                    <field name="guia"  widget="monetary"/>

                                    <field name="otros"  widget="monetary"/>

                                </group>    

                                <notebook>

                                    <page string="Lineas de Servicios">

                                        <field name="service_lines_ids" mode="tree">

                                            <form string="Líneas de Servicios">

                                                <group>

                                                    <field name="service_id"/>

                                                    <field name="pax"/>                               

                                                    <field name="pax_asignado"/>

                                                </group>                              

                                            </form>

                                            <tree>      

                                                <field name="service_id"/>

                                                <field name="pax"/>                               

                                                <field name="pax_asignado"/>

                                            </tree>                                                                                   

                                        </field> 

                                    </page>                    

                                </notebook>                         

                            </form>

                            <tree>                                

                                <field name="product_id"/>                               

                                <field name="chofer"/>

                                <field name="camioneta"/>                                

                                <field name="combustible"  widget="monetary"/>

                                <field name="entradas"  widget="monetary"/>

                                <field name="estacionamiento"  widget="monetary"/>

                                <field name="casetas"  widget="monetary"/>

                                <field name="viaticos"  widget="monetary"/>

                                <field name="derecho_piso"  widget="monetary"/>

                                <field name="guia"  widget="monetary"/>

                                <field name="otros"  widget="monetary"/>

                            </tree>                                                                                   

                        </field>                        

                    </page>                    

                </notebook>

            </sheet>            

        </form>          

      </field>

    </record> 

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

            <field name="name">page.lines.tree</field>

            <field name="model">page.lines</field>

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

                <tree string="Líneas de Páginas">

                    <field name="product_id"/>                               

                    <field name="chofer"/>

                    <field name="camioneta"/>                                

                    <field name="combustible"  widget="monetary"/>

                    <field name="entradas"  widget="monetary"/>

                    <field name="estacionamiento"  widget="monetary"/>

                    <field name="casetas"  widget="monetary"/>

                    <field name="viaticos"  widget="monetary"/>

                    <field name="derecho_piso"  widget="monetary"/>

                    <field name="guia"  widget="monetary"/>

                    <field name="otros"  widget="monetary"/>

                </tree>

            </field>

        </record>


    


    <record id="action_service_page" model="ir.actions.act_window">

      <field name="name">Hojas de Servicios</field>

      <field name="res_model">services.page</field>

      <field name="view_type">form</field>

      <field name="view_mode">tree,form</field>     

    </record>


    <menuitem id="menu_fleet_service_page"

          name="Hoja de Servicios"

          parent="fleet.menu_fleet_reporting"

          action="action_service_page"

          sequence="3"

          />  

  </data>

</openerp>

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
Failing to write Many2one field Solved
one2many create relationfield
Avatar
Avatar
1
de febr. 19
4515
Why to add Many2One field on both models?
many2one one2many relationfield
Avatar
Avatar
1
de gen. 19
10505
how pass value to on2many field from parent form via context
one2many
Avatar
Avatar
1
de gen. 25
2714
How to make tree view place last entered field on the top of tree view? What is the difference between editable="top" and editable="bottom"?
one2many
Avatar
Avatar
Avatar
2
de set. 22
10422
How to configure one2many field inside a form with domain or filter Solved
one2many
Avatar
Avatar
2
d’abr. 22
5284
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