Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Schvalování
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Food & Hospitality
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Guest House
    • Distributor nápojů
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Trades
    • Údržbář
    • IT hardware a podpora
    • Solar Energy Systems
    • Výrobce obuvi
    • Úklidové služby
    • HVAC Services
    Others
    • Nonprofit Organization
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Browse all Industries
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Services for Partners
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účetnictví
  • Sklad
  • PoS
  • Projekty
  • MRP
All apps
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

one2many field is not showing after created at new model

Odebírat

Get notified when there's activity on this post

This question has been flagged
one2manyrelationfield
5375 Zobrazení
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
Zrušit
Enjoying the discussion? Don't just read, join in!

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

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
Failing to write Many2one field Vyřešeno
one2many create relationfield
Avatar
Avatar
1
úno 19
4473
Why to add Many2One field on both models?
many2one one2many relationfield
Avatar
Avatar
1
led 19
10450
how pass value to on2many field from parent form via context
one2many
Avatar
Avatar
1
led 25
2618
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
zář 22
10371
How to configure one2many field inside a form with domain or filter Vyřešeno
one2many
Avatar
Avatar
2
dub 22
5240
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 je balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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