Skip to Content
Odoo मेन्यू
  • Sign in
  • मुफ़्त में आज़माएं
  • ऐप्लिकेशन
    फ़ाइनेंस
    • अकाउंटिंग
    • इनवॉइसिंग
    • एक्सपेंस
    • स्प्रेडशीट (बीआई)
    • डॉक्यूमेंट्स
    • साइन
    सेल्स
    • सीआरएम
    • सेल्स
    • पीओएस शॉप
    • पीओएस रेस्टोरेंट
    • सब्सक्रिप्शन
    • रेंटल
    वेबसाइट
    • वेबसाइट बिल्डर
    • ई-कॉमर्स
    • ब्लॉग
    • फ़ोरम
    • लाइव चैट
    • ई-लर्निंग
    सप्लाई चेन
    • इन्वेंट्री
    • मैन्युफ़ैक्चरिंग
    • पीएलएम
    • परचेज़
    • मेंटेनेंस
    • क्वालिटी
    मानव संसाधन
    • कर्मचारी
    • रिक्रूटमेंट
    • टाइम ऑफ़
    • अप्रेज़ल
    • रेफ़रल
    • फ़्लीट
    मार्केटिंग
    • सोशल मार्केटिंग
    • ईमेल मार्केटिंग
    • एसएमएस मार्केटिंग
    • इवेंट
    • मार्केटिंग ऑटोमेशन
    • सर्वे
    सेवाएं
    • प्रोजेक्ट
    • टाइमशीट
    • फ़ील्ड सर्विस
    • हेल्पडेस्क
    • प्लानिंग
    • अपॉइंटमेंट
    प्रॉडक्टिविटी
    • डिस्कस
    • अप्रूवल
    • आईओटी
    • वीओआईपी
    • नॉलेज
    • WhatsApp
    तीसरे पक्ष के ऐप्लिकेशन Odoo स्टूडियो Odoo क्लाउड प्लेटफ़ॉर्म
  • इंडस्ट्री
    रीटेल
    • बुक स्टोर
    • क्लोदिंग स्टोर
    • फ़र्नीचर स्टोर
    • ग्रॉसरी स्टोर
    • हार्डवेयर स्टोर
    • टॉय स्टोर
    Food & Hospitality
    • बार और पब
    • रेस्टोरेंट
    • फ़ास्ट फ़ूड
    • Guest House
    • बेवरिज डिस्ट्रीब्यूटर
    • होटल
    रियल एस्टेट
    • Real Estate Agency
    • आर्किटेक्चर फ़र्म
    • कंसट्रक्शन
    • एस्टेट मैनेजमेंट
    • गार्ड्निंग
    • प्रॉपर्टी ओनर असोसिएशन
    कंसल्टिंग
    • अकाउंटिंग फ़र्म
    • Odoo पार्टनर
    • मार्केटिंग एजेंसी
    • लॉ फ़र्म
    • टैलेंट ऐक्विज़िशन
    • ऑडिट & सर्टिफ़िकेशन
    मैन्युफ़ैक्चरिंग
    • टेक्सटाइल
    • Metal
    • फ़र्नीचर
    • फ़ूड
    • Brewery
    • कॉर्पोरेट गिफ़्ट
    हेल्थ & फिटनेस
    • स्पोर्ट्स क्लब
    • आईवियर स्टोर
    • फिटनेस सेंटर
    • वेलनेस प्रैक्टिशनर
    • फॉर्मेसी
    • हेयर सैलून
    Trades
    • Handyman
    • आईटी हॉर्डवेयर और सपोर्ट
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    अन्य
    • Nonprofit Organization
    • एन्वायरमेंटल एजेंसी
    • बिलबोर्ड रेंटल
    • फ़ोटोग्राफी
    • बाइक लीजिंग
    • सॉफ़्टवेयर रीसेलर
    Browse all Industries
  • कम्यूनिटी
    सीखें
    • ट्यूटोरियल्स
    • दस्तावेज़
    • सर्टिफ़िकेशन
    • ट्रेनिंग
    • ब्लॉग
    • पॉडकास्ट
    शिक्षा को बढ़ावा दें
    • एजुकेशन प्रोग्राम
    • स्केल अप! बिजनेस गेम
    • Odoo के ऑफ़िस में आएं
    सॉफ़्टवेयर पाएं
    • डाउनलोड
    • वर्शन की तुलना करें
    • रिलीज़
    साथ मिलकर काम करें
    • Github
    • फ़ोरम
    • इवेंट
    • अनुवाद
    • पार्टनर बनें
    • Services for Partners
    • अपना अकाउंटिंग फ़र्म रजिस्टर करें
    सेवाएं पाएं
    • पार्टनर ढूंढें
    • अकाउंटेंट खोजें
    • सलाहकार की मदद लें
    • इम्प्लिमेंटेशन सेवाएं
    • कस्टमर रेफ़रेंस
    • सहायता
    • अपग्रेड
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    डेमो देखें
  • कीमत
  • सहायता

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

  • सीआरएम
  • e-Commerce
  • लेखांकन
  • इन्वेंटरी
  • PoS
  • प्रोजेक्ट
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
Help

Custom Qweb report works in html but not in PDF

Subscribe

Get notified when there's activity on this post

This question has been flagged
qwebreportswkhtmltopdfodoo12
1 Reply
7891 Views
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
Discard
Avatar
Thomas Brouwer
Author 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
Discard
Enjoying the discussion? Don't just read, join in!

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

Sign up
Related Posts Replies Views Activity
Reporte de Odoo hecho con qweb no se actualiza
qweb reports Docker odoo12
Avatar
0
मार्च 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
जन॰ 25
46168
QWEB Report template has inconsistent row heights (see screenshot)
qweb reports
Avatar
0
अक्तू॰ 24
2333
Qweb reports inconsistent table row height
qweb reports
Avatar
0
अक्तू॰ 24
5
custom layout qweb report odoo 12 Solved
pdf qweb reports odoo odoo12
Avatar
Avatar
Avatar
2
मार्च 24
3841
कम्यूनिटी
  • ट्यूटोरियल्स
  • दस्तावेज़
  • फ़ोरम
ओपन सोर्स
  • डाउनलोड
  • Github
  • रनबॉट
  • अनुवाद
सेवाएं
  • Odoo.sh Hosting
  • सहायता
  • अपग्रेड
  • कस्टम डेवलपमेंट्स
  • शिक्षा
  • अकाउंटेंट खोजें
  • पार्टनर ढूंढें
  • पार्टनर बनें
हमारे बारे में
  • हमारी कंपनी
  • ब्रांड ऐसेट
  • संपर्क करें
  • नौकरियां
  • इवेंट
  • पॉडकास्ट
  • ब्लॉग
  • ग्राहक
  • लीगल • गोपनीयता
  • सुरक्षा
الْعَرَبيّة 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, बिज़नेस से जुड़े ऐप्लिकेशन का एक कलेक्शन है जो ओपन सोर्स पर आधारित है. इसमें आपकी कंपनी की हर ज़रूरत के लिए ऐप्लिकेशन हैं. जैसे, सीआरएम, ई-कॉमर्स, अकाउंटिंग, इन्वेंट्री, पॉइंट ऑफ़ सेल, प्रोजेक्ट मैनेजमेंट वगैरह.

Odoo की सबसे बड़ी खासियत है कि यह इस्तेमाल करने में बहुत आसान है और यह पूरी तरह से इंटिग्रेट किया हुआ है.

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