Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Validations
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Épicerie
    • Quincaillerie
    • Magasin de jouets
    Food & Hospitality
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Maison d’hôtes
    • Distributeur de boissons
    • Hôtel
    Immobilier
    • Agence immobilière
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consultance
    • Cabinet d'expertise comptable
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Métal
    • Meubles
    • Alimentation
    • Brewery
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Trades
    • Bricoleur
    • Matériel informatique et support
    • Systèmes photovoltaïques
    • Cordonnier
    • Services de nettoyage
    • Services CVC
    Autres
    • Organisation à but non lucratif
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Browse all Industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenez partenaire
    • Services for Partners
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide

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

  • CRM
  • e-Commerce
  • Comptabilité
  • Inventaire
  • PoS
  • Projet
  • MRP
All apps
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

one2many field is not showing after created at new model

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
one2manyrelationfield
5437 Vues
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
Ignorer
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
Failing to write Many2one field Résolu
one2many create relationfield
Avatar
Avatar
1
févr. 19
4547
Why to add Many2One field on both models?
many2one one2many relationfield
Avatar
Avatar
1
janv. 19
10583
how pass value to on2many field from parent form via context
one2many
Avatar
Avatar
1
janv. 25
2777
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
sept. 22
10496
How to configure one2many field inside a form with domain or filter Résolu
one2many
Avatar
Avatar
2
avr. 22
5334
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenez partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة 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 est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

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