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

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
11138 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.

Registrarse
Publicaciones relacionadas Respuestas Vistas Actividad
How to overwrite field string name?
field qweb js
Avatar
Avatar
1
sept 19
6840
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
9753
Odoo 18: Display image from char field containing url in qweb form
qweb
Avatar
Avatar
1
jul 25
3012
PDF Export Option for QWeb Reports in odoo 17.0
qweb
Avatar
Avatar
1
may 25
3820
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.

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