Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Estate Managament
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

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

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

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

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
fieldqwebrelations
2 Răspunsuri
11140 Vizualizări
Imagine profil
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
Imagine profil
Abandonează
Imagine profil
Art
Cel mai bun răspuns

@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
Imagine profil
Abandonează
Imagine profil
Saitam
Autor Cel mai bun răspuns

@ 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
Imagine profil
Abandonează
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.

Enjoying the discussion? Don't just read, join in!

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

Înscrie-te
Related Posts Răspunsuri Vizualizări Activitate
How to overwrite field string name?
field qweb js
Imagine profil
Imagine profil
1
sept. 19
6840
How to overwrite field name?
field qweb js backbone.js
Imagine profil
0
sept. 19
7
How to define a read only field
field qweb readonly odooV8
Imagine profil
Imagine profil
Imagine profil
5
feb. 16
9753
Odoo 18: Display image from char field containing url in qweb form
qweb
Imagine profil
Imagine profil
1
iul. 25
3016
PDF Export Option for QWeb Reports in odoo 17.0
qweb
Imagine profil
Imagine profil
1
mai 25
3825
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة 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 este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

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