Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

249
Views
how to print div from html to qweb report in invoice (website) ? Odoo 14

In the 'report_invoice_document' report, I added :

  <t t-if="report_type == 'html'">
      <div class="from_website" >
           <strong> Printed From Invoice</strong>
      </div>
  </t>

I want to get this div only when printing or downloding from website side .

How can I do it without modifying the content of the report generated from backend. Any help please ? Thanks. enter image description here enter image description here

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

You can use the website variable to check if the invoice report is printed from the website

website
the current website object, if any (this item can be present but None)

Try the following code:

<t t-if="website">
    <div class="from_website" >
        <strong> Printed From Website</strong>
    </div>
</t>

Edit (Report Preview)

You can add an extra parameter to the report URL (inside the report_pdf_preview.js file ?variable_name=) and alter the _render_template function to add a new report value based on the URL parameter then use it inside the template to hide text if the user uses the report preview.

Example:

class IrActionsReport(models.Model):
    _inherit = 'ir.actions.report'
    
    def _render_template(self, template, values=None):
        values['pdf_preview'] = request.params.get('pdf_preview')
        return super(IrActionsReport, self)._render_template(template, values=values)

You can hide an element like following:

<div t-if="not pdf_preview and website">
  From website
</div>
about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!