Ir al contenido
Odoo Menú
  • Iniciar sesión
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • PdV para tiendas
    • PdV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en vivo
    • eLearning
    Cadena de suministro
    • Inventario
    • Manufactura
    • PLM
    • Compras
    • Mantenimiento
    • Calidad
    Recursos humanos
    • Empleados
    • Reclutamiento
    • Vacaciones
    • Evaluaciones
    • Referencias
    • Flotilla
    Marketing
    • Redes sociales
    • Marketing por correo
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyectos
    • Registro de horas
    • Servicio externo
    • Soporte al cliente
    • Planeación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Artículos
    • WhatsApp
    Aplicaciones externas Studio de Odoo Plataforma de Odoo en la nube
  • Industrias
    Venta minorista
    • Librería
    • Tienda de ropa
    • Mueblería
    • Tienda de abarrotes
    • Ferretería
    • Juguetería
    Alimentos y hospitalidad
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidora de bebidas
    • Hotel
    Bienes inmuebles
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión de bienes inmuebles
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Firma contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Manufactura
    • Textil
    • Metal
    • Muebles
    • Comida
    • Cervecería
    • Regalos corporativos
    Salud y ejercicio
    • Club deportivo
    • Óptica
    • Gimnasio
    • Especialistas en bienestar
    • Farmacia
    • Peluquería
    Trades
    • Personal de mantenimiento
    • Hardware y soporte de TI
    • Sistemas de energía solar
    • Zapateros y fabricantes de calzado
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin fines de lucro
    • Agencia para la protección del medio ambiente
    • Alquiler de anuncios publicitarios
    • Fotografía
    • Alquiler de bicicletas
    • Distribuidor de software
    Descubre todas las industrias
  • Odoo Community
    Aprende
    • Tutoriales
    • Documentación
    • Certificaciones
    • Capacitación
    • Blog
    • Podcast
    Fortalece la educación
    • Programa educativo
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtén el software
    • Descargar
    • Compara ediciones
    • Versiones
    Colabora
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Conviértete en partner
    • Servicios para partners
    • Registra tu firma contable
    Obtén servicios
    • Encuentra un partner
    • Encuentra un contador
    • Contacta a un consultor
    • Servicios de implementación
    • Referencias de clientes
    • Soporte
    • Actualizaciones
    GitHub YouTube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicita una demostración
  • Precios
  • Ayuda

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

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyectos
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

To dispaly all records in tree view of one2many relation without specifying “foreign key field”

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
xmlodooone2many_list
4 Respuestas
16383 Vistas
Avatar
Silviaa

Im creating a new model not stored in Database .Field "pricelist_item_id" in one2manyrelation without inverse_name.

 class Product_Price_Search(models.Model):
    _name = 'product.price.search'  

  _auto = False
    upgrade_price = fields.Integer('Upgrade Price')  

  pricelist_item_id = fields.One2many(          'product.pricelist.item',          string="Product PriceList Items"    )


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

        <field name="name">product.price.search.form.view</field>         

       <field name="model">product.price.search</field>       

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

        <form string="PriceList Items Form">             

       <sheet><group col="2">  

        <field name="upgrade_price" />                

                                 </group>                   

                             <!-- PriceList Items Tree View -->         

                         <group string="Form">             

                        <div>     <p>      List PriceList Items      </p>                 

                       </div>     </group>              

           <field name="pricelist_item_id">  

           <tree string='Tables'>    

          <field name="name" />    

        <field name="product_id" />   

          </tree>              

         </field>    

        </sheet>            

        </form>      

      </field>    

    </record>


In my "pricelist_item_id" fields in tree .
I want to display all the records which is available in that table .
Isit possible in Odoo ?



1
Avatar
Descartar
Anil Kesariya

What is the reason for not adding foreign key? If you want use one2many you must need to define reference/ID inside the comodel. without that not possible.

Anil Kesariya

If you don't want any reference field than go for the Text field make it as compute/functional field and fetch the data of all the records and display in your text box in appropriate format. this could be done without any foreign key.

Avatar
Muhammed Nishad
Mejor respuesta

Dear Silviaa,

          According my knowledge , One2many is a virtual field.Since it is It must have a Many2one model behind.So that it,s data can be linked to the current record on the self.

for eg:

class Target(models.Model):
_name = 'projection.target'
_rec_name = 'sales_man'
_sql_constraints = [('sales_man', 'UNIQUE(sales_man)', 'The employee has already assigned to a target'), ]
sales_man = fields.Many2one('res.users', string="Select Employee", required=True)
working_days = fields.Integer(compute="computewkng")
target = fields.Char(string='Total Projection', readonly=True, compute='totalprojection')
sal = fields.Float(string='Achievement', compute="calculatetotalsales", readonly=True)
average = fields.Float(String='Average', compute='computeavg')
variance = fields.Float(string='Variance', compute='computevariance')
data = fields.One2many('projection.onetomanydata', 'inv', ondelete='cascade')
 #this model has a One2many field that is linked with the Many2one on another module
class OneToManyData(models.Model):
_name = 'projection.onetomanydata'
_rec_name = 'name'
_sql_constraints = [('date', 'UNIQUE(date)', 'Employee Has Already Assigned to a Target on This date'), ]
name = fields.Char(default='Daily Projection', invisible=True)
date = fields.Date(string="Date", required=True)
target = fields.Integer(string="Daily Projection", required=True)
inv = fields.Many2one('projection.target')
#here the inv links this model to the first one
#its just a matter of 2 lines of code.
3
Avatar
Descartar
Avatar
Pratik Bhandirge
Mejor respuesta

one2many field attributes, comodel_name, and inverse_name (i.e. foreign key) are mandatory except in the case of related fields or field extensions.


In your case, you can display all records in wizard on button click...
1
Avatar
Descartar
¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Registrarse
Publicaciones relacionadas Respuestas Vistas Actividad
Problemas al imprimir factura en el odoo
xml odoo
Avatar
0
ene 25
2076
How to post xml code
xml odoo
Avatar
1
mar 25
652
How can I include my generic qweb view on my Odoo 16 Form View using JS or Controller
xml odoo
Avatar
Avatar
1
sept 23
3704
Favorite filter Odoo 10 Resuelto
xml odoo
Avatar
Avatar
2
ago 22
8504
[Odoo 8]How to use ref on domain xml Resuelto
xml odoo
Avatar
Avatar
Avatar
Avatar
Avatar
8
jun 20
23206
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento en Odoo.sh
  • Soporte
  • Actualizaciones del software
  • Desarrollos personalizados
  • Educación
  • Encuentra un contador
  • Encuentra un partner
  • Conviértete en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contáctanos
  • Empleos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Legal • Privacidad
  • Seguridad
الْعَرَبيّة 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 es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y estar totalmente integrado.

Sitio web hecho con

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