Ir al contenido
Odoo Menú
  • Identificarse
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • TPV para tiendas
    • TPV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en directo
    • eLearning
    Cadena de suministro
    • Inventario
    • Fabricación
    • PLM
    • Compra
    • Mantenimiento
    • Calidad
    Recursos Humanos
    • Empleados
    • Reclutamiento
    • Ausencias
    • Evaluación
    • Referencias
    • Flota
    Marketing
    • Marketing social
    • Marketing por correo electrónico
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyecto
    • Partes de horas
    • Servicio de campo
    • Servicio de asistencia
    • Planificación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Conocimientos
    • WhatsApp
    Aplicaciones de terceros Studio de Odoo Plataforma de Odoo Cloud
  • Industrias
    Comercio al por menor
    • Librería
    • Tienda de ropa
    • Tienda de muebles
    • Tienda de ultramarinos
    • Ferretería
    • Juguetería
    Alimentación y hostelería
    • Bar y taberna
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidor de bebidas
    • Hotel
    Inmueble
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión inmobiliaria
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Empresa contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Fabricación
    • Textil
    • Metal
    • Muebles
    • Alimentos
    • Brewery
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Oficios
    • Handyman
    • Hardware y asistencia informática
    • Sistemas de energía solar
    • Zapatero
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin ánimo de lucro
    • Agencia de protección del medio ambiente
    • Alquiler de paneles publicitarios
    • Estudio fotográfico
    • Alquiler de bicicletas
    • Distribuidor de software
    Browse all Industries
  • Comunidad
    Aprender
    • Tutoriales
    • Documentación
    • Certificaciones
    • Formación
    • Blog
    • Podcast
    Potenciar la educación
    • Programa de formación
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtener el software
    • Descargar
    • Comparar ediciones
    • Versiones
    Colaborar
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Convertirse en partner
    • Services for Partners
    • Registrar tu empresa contable
    Obtener servicios
    • Encontrar un partner
    • Encontrar un asesor fiscal
    • Contacta con un experto
    • Servicios de implementación
    • Referencias de clientes
    • Ayuda
    • Actualizaciones
    GitHub YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicitar 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
  • Proyecto
  • 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

Odoo 10: show field of model “sale.order” in form view of “account.invoice”

Suscribirse

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

Se marcó esta pregunta
fieldqwebrelations
2 Respuestas
11136 Vistas
Avatar
Saitam

I usually create a new Field by using the Debugging Mode and then clicking "Edit FormView" when I am on the appropriate form and writing into the code something like:

<field name="x_delivery_date"/>. 

Also I can show it afterwards on the printed report like this:

<div name="x_delivery_date" t-if="doc.x_delivery_date">    
<strong>Delivery Date:</strong>   
 <p t-field="doc.x_delivery_date"/>
</div>

But how do I display a field (commitment_date), which is available in the model (sale.order) in another models formview (account.invoice)? I guess that I have to use object relations or related field, but I don't know how. I hope somebody can help me. Many thanks in advance.

0
Avatar
Descartar
Avatar
Art
Mejor respuesta

@Saitam

Try this, it works! I created 'commitment_date' field in 'sale.order' and added it to 'account.invoice':

class AddCommitmentDate(models.Model):
    _inherit = 'sale.order'
    commitment_date = fields.Date('Commitment Date')

class AddToAccountInvoice(models.Model):
    _inherit = 'account.invoice'
    sale_order_id = fields.Many2one('sale.order', 'Orders')
    commitment_date = fields.Date(related='sale_order_id.commitment_date')
<record id="test_commitment_field_id" model="ir.ui.view">        
    <field name="name">Add commitment field</field>
    <field name="model">account.invoice</field>
    <field name="inherit_id" ref="account.invoice_form"/>
    <field name="arch" type="xml">
        <field name="date_invoice" position="after">
            <field name="commitment_date"/>
        </field>
    </field>
</record>


 

0
Avatar
Descartar
Avatar
Saitam
Autor Mejor respuesta

@ Art

It doesn't work like this. There is no connection between sale order and account invoice. If I add the following line to account_invoice.py I get a 500 Internal Server Error:
`commitment_date = fields.Date(related='sale_order.commitment_date')`

I am writing this as an answer and not as a comment, because I am new to this forum and I only can comment with 8 carma points but have only gotten 7 carma points with the registration here (which makes absolutely no sense!) .


This my model:

class AccountInvoice(models.Model):
    _name = "account.invoice"
    _inherit = ['mail.thread']       
    _description = "Invoice"       
    _order = "date_invoice desc, number desc, id desc"        
    
    commitment_date = fields.Date(related='sale_order.commitment_date')    
    
    ...

And here is my view code, but the Odoo server doesn't start after the modificated model, so I don't even know if the view code would work or not:

<div name="commitment_date" class="col-xs-3">                    
<strong>Date:</strong>                   
<p t-field="o.sale_order.commitment_date"/>               
</div>


0
Avatar
Descartar
Art

show us your model and view code.

Art

I cant' get it working yet... trying to understand how related fields work.

Art

So here is a short info from a odoo blogger about related fields: "We have to give/add Many2one(sale.order) field in account.invoice object. We can fill up new Many2one(sale.order) field id when invoice create from Sale order or Delivery order based on our Invoice control policy or Product setups. Afterwards you can declare your new field with related like Many2one(sale.order).validity_date. If you don't want to go with related field then we can override few existing method and fill up Expiration date in account.invoice object."

=======

So I tried to add an existing field (validity_date) from sale.order to account.invoice like this:

class AddToAccountInvoice(models.Model):

_inherit = 'account.invoice'

date_id = fields.Many2one('sale.order', 'My Date')

validity_date = fields.Date(related='date_id.validity_date')

but I get "AssertionError: Document does not comply with schema." So looks like Many2one field needs to be created to deal with this issue, just need to figure out the right way.

Art

Ok, I'm stupid. I was getting this AssertionError because I didn't have <odoo> and <data> tags in my xml view.

I have edited my answer. Hope it'll help you.

¿Le interesa esta conversación? ¡Participe en ella!

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

Inscribirse
Publicaciones relacionadas Respuestas Vistas Actividad
How to overwrite field string name?
field qweb js
Avatar
Avatar
1
sept 19
6839
How to overwrite field name?
field qweb js backbone.js
Avatar
0
sept 19
7
How to define a read only field
field qweb readonly odooV8
Avatar
Avatar
Avatar
5
feb 16
9748
Odoo 18: Display image from char field containing url in qweb form
qweb
Avatar
Avatar
1
jul 25
3010
PDF Export Option for QWeb Reports in odoo 17.0
qweb
Avatar
Avatar
1
may 25
3811
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento Odoo.sh
  • Ayuda
  • Actualizar
  • Desarrollos personalizados
  • Educación
  • Encontrar un asesor fiscal
  • Encontrar un partner
  • Convertirse en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contacta con nosotros
  • Puestos de trabajo
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Información 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 totalmente integrado.

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