Skip to Content
Odoo Menu
  • Prijavi
  • Try it free
  • Aplikacije
    Finance
    • Knjigovodstvo
    • Obračun
    • Stroški
    • Spreadsheet (BI)
    • Dokumenti
    • Podpisovanje
    Prodaja
    • CRM
    • Prodaja
    • POS Shop
    • POS Restaurant
    • Naročnine
    • Najem
    Spletne strani
    • Website Builder
    • Spletna trgovina
    • Blog
    • Forum
    • Pogovor v živo
    • eUčenje
    Dobavna veriga
    • Zaloga
    • Proizvodnja
    • PLM
    • Nabava
    • Vzdrževanje
    • Kakovost
    Kadri
    • Kadri
    • Kadrovanje
    • Odsotnost
    • Ocenjevanja
    • Priporočila
    • Vozni park
    Marketing
    • Družbeno Trženje
    • Email Marketing
    • SMS Marketing
    • Dogodki
    • Avtomatizacija trženja
    • Ankete
    Storitve
    • Projekt
    • Časovnice
    • Storitve na terenu
    • Služba za pomoč
    • Načrtovanje
    • Termini
    Produktivnost
    • Razprave
    • Odobritve
    • IoT
    • Voip
    • Znanje
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industrije
    Trgovina na drobno
    • Book Store
    • Trgovina z oblačili
    • Trgovina s pohištvom
    • Grocery Store
    • Trgovina s strojno opremo računalnikov
    • Trgovina z igračami
    Food & Hospitality
    • Bar and Pub
    • Restavracija
    • Hitra hrana
    • Guest House
    • Beverage Distributor
    • Hotel
    Nepremičnine
    • Real Estate Agency
    • Arhitekturno podjetje
    • Gradbeništvo
    • Estate Management
    • Vrtnarjenje
    • Združenje lastnikov nepremičnin
    Svetovanje
    • Računovodsko podjetje
    • Odoo Partner
    • Marketinška agencija
    • Law firm
    • Pridobivanje talentov
    • Audit & Certification
    Proizvodnja
    • Tekstil
    • Metal
    • Pohištvo
    • Hrana
    • Brewery
    • Poslovna darila
    Health & Fitness
    • Športni klub
    • Trgovina z očali
    • Fitnes center
    • Wellness Practitioners
    • Lekarna
    • Frizerski salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Sistemi sončne energije
    • Izdelovalec čevljev
    • Čistilne storitve
    • HVAC Services
    Ostali
    • Neprofitna organizacija
    • Agencija za okolje
    • Najem oglasnih panojev
    • Fotografija
    • Najem koles
    • Prodajalec programske opreme
    Browse all Industries
  • Skupnost
    Learn
    • Tutorials
    • Dokumentacija
    • Certifikati
    • Šolanje
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Prenesi
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Dogodki
    • Prevodi
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Sklici kupca
    • Podpora
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Določanje cen
  • Pomoč

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

  • CRM
  • e-Commerce
  • Knjigovodstvo
  • Zaloga
  • PoS
  • Projekt
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
Pomoč

Custom Qweb report works in html but not in PDF

Naroči se

Get notified when there's activity on this post

This question has been flagged
qwebreportswkhtmltopdfodoo12
1 Odgovori
7892 Prikazi
Avatar
Thomas Brouwer

Hi ! I have a problem while generating a custom qweb report on Odoo 12.

In HTML, my report works fine, but when I want to generate it in PDF, I have the following error.

Odoo Server Error
Traceback (most recent call last): File "/home/thomas/Documents/Developpement/odoo/odoo/tools/safe_eval.py", line 350, in safe_eval return unsafe_eval(c, globals_dict, locals_dict) File "", line 1, in <module> NameError: name 'menuweek_report' is not defined During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/thomas/Documents/Developpement/odoo/addons/web/controllers/main.py", line 1684, in report_download report_name = safe_eval(report.print_report_name, {'object': obj, 'time': time}) File "/home/thomas/Documents/Developpement/odoo/odoo/tools/safe_eval.py", line 373, in safe_eval pycompat.reraise(ValueError, ValueError('%s: "%s" while evaluating\n%r' % (ustr(type(e)), ustr(e), expr)), exc_info[2]) File "/home/thomas/Documents/Developpement/odoo/odoo/tools/pycompat.py", line 86, in reraise raise value.with_traceback(tb) File "/home/thomas/Documents/Developpement/odoo/odoo/tools/safe_eval.py", line 350, in safe_eval return unsafe_eval(c, globals_dict, locals_dict) File "", line 1, in <module> ValueError: <class 'NameError'>: "name 'menuweek_report' is not defined" while evaluating 'menuweek_report' 

Here my report define in my XML file :

<odoo>
<report
id="action_report_menu"
string="Weeks menu"
model="dt.menu"
report_type="qweb-pdf"
name="dietetique.menuweek_report"
print_report_name="menuweek_report"
/>

<template id="menuweek_report">
<t t-call="web.html_container">
<t t-call="web.basic_layout">
<div class="article">
<hr />
<h2>Week's menu</h2>

<table class="table table-bordered">
<thead>
<tr>
<th></th>
<th>Monday</th>
<th>Tuesday</th>
<th>Wednesday</th>
<th>Thursday</th>
<th>Friday</th>
<th>Saturday</th>
<th>Sunday</th>
</tr>
</thead>

<tbody>
<tr>
<td>Breakfast</td>
<t t-foreach="data['breakfast']" t-as="breakfast">
<td><span t-esc="breakfast" /></td>
</t>
</tr>

<tr>
<td>Lunch</td>
<t t-foreach="data['lunch']" t-as="lunch">
<td><span t-esc="lunch" /></td>
</t>
</tr>

<tr>
<td>Snack</td>
<t t-foreach="data['snack']" t-as="snack">
<td><span t-esc="snack" /></td>
</t>
</tr>

<tr>
<td>Dinner</td>
<t t-foreach="data['dinner']" t-as="dinner">
<td><span t-esc="dinner" /></td>
</t>
</tr>
</tbody>
</table>
</div>
</t>
</t>
</template>
</odoo>

And here my Python code :


class MenuReport(models.AbstractModel):
_name = 'report.dietetique.menuweek_report'
_description = 'report menu'

@api.model
def _get_report_values(self, docids, data=None):
report_obj = self.env['ir.actions.report']
report = report_obj._get_report_from_name('dietetique.menuweek_report')

selected_menu = self.env['dt.menu'].sudo().search([
('id', '=', docids[0])
])

day = self.first_date_of_week(selected_menu.date.year, selected_menu.week_number) - timedelta(days=1)
start_date = day + timedelta(days=1)
end_date = start_date + timedelta(days=7)
breakfast = []
lunch = []
dinner = []
snack = []

i = 0
while i < 7:
day = day + timedelta(days=1)

menu_day = self.env['dt.menu'].sudo().search([
('date', '=', day)
])


breakfast.append((menu_day.breakfast_recipe.title if menu_day.breakfast_recipe.id else menu_day.breakfast_description))
lunch.append((menu_day.lunch_recipe.title if menu_day.lunch_recipe.id else menu_day.lunch_description))
dinner.append((menu_day.dinner_recipe.title if menu_day.dinner_recipe.id else menu_day.dinner_description))
snack.append((menu_day.snack_recipe.title if menu_day.snack_recipe.id else menu_day.snack_description))

i += 1

data = {
'start_date': start_date,
'end_date': end_date,
'breakfast': breakfast,
'lunch': lunch,
'dinner': dinner,
'snack': snack
}

docargs = {
'doc_ids': docids,
'doc_model': report.model,
'docs': self,
'data': data
}
return docargs

def first_date_of_week (self, year, week):
return datetime.strptime(f'{year}-W{int(week) - 1}-1', "%Y-W%W-%w").date()


I tried to unistall / reinstall wkhtmltopdf with no success ... I thing the problem is in the print_report_name attribute but I'm not sure !

If you can help you'll save my life :)

Thanks!         


0
Avatar
Opusti
Avatar
Thomas Brouwer
Avtor Best Answer

Found how to do ... I just put something like : 

print_report_name="('menu_'+str(object.week_number))"

And it works ... Sorry for that, topic can be mark as solved ;)

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

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

Prijavi
Related Posts Odgovori Prikazi Aktivnost
Reporte de Odoo hecho con qweb no se actualiza
qweb reports Docker odoo12
Avatar
0
mar. 25
1329
How to Change TABLE Format in QWEB reports? With different table Border and Color.? Solved
qweb reports
Avatar
Avatar
Avatar
Avatar
Avatar
4
jan. 25
46171
QWEB Report template has inconsistent row heights (see screenshot)
qweb reports
Avatar
0
okt. 24
2334
Qweb reports inconsistent table row height
qweb reports
Avatar
0
okt. 24
5
custom layout qweb report odoo 12 Solved
pdf qweb reports odoo odoo12
Avatar
Avatar
Avatar
2
mar. 24
3841
Community
  • Tutorials
  • Dokumentacija
  • Forum
Open Source
  • Prenesi
  • Github
  • Runbot
  • Prevodi
Services
  • Odoo.sh Hosting
  • Podpora
  • Nadgradnja
  • Custom Developments
  • Izobraževanje
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Sredstva blagovne znamke
  • Kontakt
  • Zaposlitve
  • Dogodki
  • Podcast
  • Blog
  • Stranke
  • Pravno • Zasebnost
  • Varnost
الْعَرَبيّة 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 is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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