Skip to Content
Odoo Menu
  • Prisijungti
  • Išbandykite nemokamai
  • Programėlės
    Finansai
    • Apskaita
    • Pateikimas apmokėjimui
    • Sąnaudos
    • Skaičiuoklė (BI)
    • Dokumentai
    • Pasirašymas
    Pardavimai
    • CRM
    • Pardavimai
    • Kasų sistema - Parduotuvė
    • Kasų sistema - Restoranas
    • Prenumeratos
    • Nuoma
    Svetainės
    • Svetainių kūrėjimo įrankis
    • El. Prekyba
    • Internetinis Tinklaraštis
    • Forumas
    • Tiesioginis pokalbis
    • eMokymasis
    Tiekimo grandinė
    • Atsarga
    • Gamyba
    • PLM
    • Įsigijimai
    • Priežiūra
    • Kokybė
    Žmogaus ištekliai
    • Darbuotojai
    • Įdarbinimas
    • Atostogos
    • Įvertinimai
    • Rekomendacijos
    • Transporto priemonės
    Rinkodara
    • Socialinė rinkodara
    • Rinkodara el. paštu
    • SMS rinkodara
    • Renginiai
    • Rinkodaros automatizavimas
    • Apklausos
    Paslaugos
    • Projektas
    • Darbo laiko žiniaraščiai
    • Priežiūros tarnyba
    • Pagalbos tarnyba
    • Planavimas
    • Rezervacijos
    Produktyvumas
    • Diskucija
    • Patvirtinimai
    • IoT
    • VoIP
    • Žinių biblioteka
    • WhatsApp
    Trečiųjų šalių programos Odoo Studija Odoo debesijos platforma
  • Pramonės šakos
    Mažmeninė prekyba
    • Knygynas
    • Drabužių parduotuvė
    • Baldų parduotuvė
    • Maisto prekių parduotuvė
    • Techninės įrangos parduotuvė
    • Žaislų parduotuvė
    Food & Hospitality
    • Barai ir pub'ai
    • Restoranas
    • Greitasis maistas
    • Guest House
    • Gėrimų platintojas
    • Hotel
    Nekilnojamasis turtas
    • Real Estate Agency
    • Architektūros įmonė
    • Konstrukcija
    • Estate Managament
    • Sodininkauti
    • Turto savininkų asociacija
    Konsultavimas
    • Accounting Firm
    • Odoo Partneris
    • Marketing Agency
    • Teisinė firma
    • Talentų paieška
    • Auditai & sertifikavimas
    Gamyba
    • Textile
    • Metal
    • Furnitures
    • Maistas
    • Brewery
    • Įmonių dovanos
    Sveikata & Fitnesas
    • Sporto klubas
    • Akinių parduotuvė
    • Fitneso Centras
    • Sveikatos praktikai
    • Vaistinė
    • Kirpėjas
    Trades
    • Handyman
    • IT įranga ir palaikymas
    • Saulės energijos sistemos
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Kiti
    • Nonprofit Organization
    • Aplinkos agentūra
    • Reklaminių stendų nuoma
    • Fotografavimas
    • Dviračių nuoma
    • Programinės įrangos perpardavėjas
    Browse all Industries
  • Bendrija
    Mokykitės
    • Mokomosios medžiagos
    • Dokumentacija
    • Sertifikatai
    • Mokymai
    • Internetinis Tinklaraštis
    • Tinklalaidės
    Skatinkite švietinimą
    • Švietimo programa
    • Scale Up! Verslo žaidimas
    • Aplankykite Odoo
    Gaukite programinę įrangą
    • Atsisiųsti
    • Palyginkite versijas
    • Leidimai
    Bendradarbiauti
    • Github
    • Forumas
    • Renginiai
    • Vertimai
    • Tapkite partneriu
    • Services for Partners
    • Registruokite jūsų apskaitos įmonę
    Gaukite paslaugas
    • Susiraskite partnerį
    • Susirask buhalterį
    • Susitikti su konsultantu
    • Diegimo paslaugos
    • Klientų rekomendavimas
    • Palaikymas
    • Atnaujinimai
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Gaukite demo
  • Kainodara
  • Pagalba

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

  • CRM
  • e-Commerce
  • Apskaita
  • Atsarga
  • PoS
  • Projektas
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
Pagalba

How can I add custom fields to the sale order print template?

Prenumeruoti

Get notified when there's activity on this post

This question has been flagged
v8printsale.order
3 Replies
13631 Rodiniai
Portretas
Peter Nietz

We have added some extra fields to the model sale.order.line. The values in these fields are needed for some automatic calculations we do in our modules. Our code looks similar to this (minimal example):

class sale_order_line(models.Model):
    _inherit = 'sale.order.line'
    myfield1 = fields.Char(string='License key', required=False)
    myfield2 = fields.Date(string='Start date', required=False)

However we need to show these values on the printed sale order as well. Therefore we tried to extend the sale order template to include these values right behind the name field. This looks like follows:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <template id="my_report_saleorder_document" inherit_id="sale.report_saleorder_document">
            <xpath expr="//span[@t-field='l.name']" position="after">
                <span t-field="l.myfield1"/>
                <span t-field="l.myfield2"/>
            </xpath>
        </template>
    </data>
</openerp>

Unfortunately this extended template seems to have no effect. Odoo still uses the standard template and our custom fields are not shown. How can we tell Odoo to use the modified template?

 

EDIT: In the meantime we investigated a little more on the inner workings of sale order printing. It seems to be the case that Odoo has a template 'sale.report_saleorder' which in turn includes the template 'sale.report_saleorder_document':

<template id="report_saleorder">
    <t t-call="report.html_container">
        <t t-foreach="doc_ids" t-as="doc_id">
            <t t-raw="translate_doc(doc_id, doc_model, 'partner_id.lang', 'sale.report_saleorder_document')"/>
        </t>
    </t>
</template>

Our inherited version of the included template of course has a different ID 'mymodule.my_report_saleorder_document'. Maybe the problem is that the "master template" still includes the old version of the "inner template" instead of our new inherited version? But this would mean that there are two different types of "inheritance" in Odoo? Also the module sale_layout seems to do it the same way we do it? We are confused...

 

0
Portretas
Atmesti
Portretas
Muhammad Hassan
Best Answer

I applied same logic but my field value is not displaying and parent view can not be located error occurs

0
Portretas
Atmesti
Portretas
Zbik
Best Answer
  1. Probably you need a record:

    'depends': [ 'sale' ],

in your module, in __openerp__.py

2. You change

myfield1 = fields.Char()
myfield2 = fields.Date()

by

myfield1 = fields.Char('FOO NAME')
myfield2 = fields.Date('FOO DATE NAME')

3. Probably the values in these fields are empty and therefore do not see them in report

0
Portretas
Atmesti
Peter Nietz
Autorius

We already have that in our module: "depends" : [ "base", "web", "account", "sale" ]

Zbik

You have installed sale_layout module?

Peter Nietz
Autorius

No, we did not have sale_layout installed. We have catched up with that now, but apparently it does not make any difference whether it is installed or not.

Zbik

Answer updated

Peter Nietz
Autorius

Okay, apparently we reduced the code too much to provide a minimal example. We have changed the example code above to be closer to our actual production code. We also added another thought above.

Zbik

You code works without any problem in my test system.

Zbik

You inherit sale.order in other custom module? Eg. if sale_layout is installed he would replace a part of the report template (this with your code).

Portretas
Ankit H Gandhi(AHG)
Best Answer

Hello Peter Nietz,

Use below code may be help you.

<template id="my_report_saleorder_document" inherit_id="sale.report_saleorder_document">
                <xpath expr="//table[@class='table table-condensed']/thead/tr/th[1]" position="after">
                       <th>License key</th>
                       <th>Start date</th>
                </xpath>
                <xpath expr="//table[@class='table table-condensed']/tbody[@class='sale_tbody']/tr/td[1]" position="after">
                       <td><span t-field="l.myfield1"/></td>              
                       <td><span t-field="l.myfield2"/></td>
                </xpath>
        </template>

if you find this answer helpful, please give me a thumbs up vote

Regards,

Ankit H Gandhi

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

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

Registracija
Related Posts Replies Rodiniai Veikla
Create a print view for a tree view
v8 print
Portretas
Portretas
1
liep. 15
9792
Email template is failed to render ? [SOLVED] Solved
v8 sale.order email_template
Portretas
Portretas
Portretas
Portretas
4
saus. 19
33129
How to modify count total amount in sale order? [SOLVED] Solved
v8 sale.order override
Portretas
Portretas
Portretas
3
saus. 18
10046
Where is it possible to view the "Warning message" as defined in product form?
message v8 sale.order
Portretas
0
geg. 16
4518
v8: Error when print BoM
v8 print bom
Portretas
0
kov. 15
4760
Bendrija
  • Mokomosios medžiagos
  • Dokumentacija
  • Forumas
Atvirasis kodas
  • Atsisiųsti
  • Github
  • Runbot
  • Vertimai
Paslaugos
  • Odoo.sh talpinimas
  • Palaikymas
  • Atnaujinti
  • Pritaikytas programavimo kūrimas
  • Švietimas
  • Susirask buhalterį
  • Susiraskite partnerį
  • Tapkite partneriu
Apie mus
  • Mūsų įmonė
  • Prekės ženklo turtas
  • Susisiekite su mumis
  • Darbo pasiūlymai
  • Renginiai
  • Tinklalaidės
  • Internetinis Tinklaraštis
  • Klientai
  • Teisinis • Privatumas
  • Saugumas
الْعَرَبيّة 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 yra atvirojo kodo verslo programų rinkinys, kuris apima visas įmonės poreikius: CRM, El. Prekybą, Apskaitą, Atsargų, Kasų sistemą, Projektų valdymą ir kt.

Unikali Odoo vertės pasiūla – būti tuo pačiu metu labai lengvai naudojama ir visiškai integruota sistema.

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