Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

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

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

Getting error: TemplateAssertionError: no filter named 'n' when printing report?

Subscribe

Get notified when there's activity on this post

This question has been flagged
v8webkitwebkit_reportjinja2
1 Reply
9911 Views
Avatar
Yakito

I am trying to print a report for a custom module I am building with Odoo, but when I try to print I get the following error:

File "/opt/odoo/openerp/service/report.py", line 93, in go result, format = openerp.report.render_report(cr, uid, ids, object, datas, context) File "/opt/odoo/openerp/report/__init__.py", line 40, in render_report return registry['ir.actions.report.xml'].render_report(cr, uid, ids, name, data, context) File "/opt/odoo/openerp/api.py", line 241, in wrapper return old_api(self, *args, **kwargs) File "/opt/odoo/openerp/addons/base/ir/ir_actions.py", line 155, in render_report return new_report.create(cr, uid, res_ids, data, context) File "/opt/odoo/addons/report_webkit/webkit_report.py", line 376, in create result = self.create_source_pdf(cursor, uid, ids, data, report_xml, context) File "/opt/odoo/openerp/report/report_sxw.py", line 461, in create_source_pdf return self.create_single_pdf(cr, uid, ids, data, report_xml, context) File "/opt/odoo/addons/report_webkit/webkit_report.py", line 334, in create_single_pdf head_mako_tpl = mako_template(header) File "/opt/odoo/addons/report_webkit/webkit_report.py", line 88, in mako_template return mako_template_env.from_string(text) File "/usr/local/lib/python2.7/dist-packages/Jinja2-2.6-py2.7.egg/jinja2/environment.py", line 769, in from_string return cls.from_code(self, self.compile(source), globals, None) File "/usr/local/lib/python2.7/dist-packages/Jinja2-2.6-py2.7.egg/jinja2/environment.py", line 493, in compile self.handle_exception(exc_info, source_hint=source) File "<unknown>", line 24, in template TemplateAssertionError: no filter named 'n'

I googled a lot and couldn't find any clue as to how to solve that issue.

I am using webkit reporting. Here is my .mako file.

<html> <head> <style type="text/css"> </style> </head> <body> Testing </body> </html>

This is how I call the report from the .py file

report_sxw.report_sxw('report.hotel.webkit', 'hotel.webkit', 'addons/hotel_webkit/report/report_hotel.mako', parser=report_webkit_html)

And finally the XML call

<report id="sim.report_sim_hotel" name="hotel.webkit" auto="False" model="sim.resumen_wizard" file="hotel_webkit/report/report_hotel.mako" string="Hotel Report Test" webkit_header="base_headers_webkit.base_reports_portrait_header" report_type="webkit"/>

Any clue as to what does that error means and what else can I test to make the report work will be appreciated.

Thanks

0
Avatar
Discard
Avatar
Nicholas Tring
Best Answer

I just fixed this issue for our invoices.

Odoo switched from Mako in v7 to Jinja2 in v8, with a "simulated" Mako notation where _most_ things work as before. Inline Python code doesn't, this "n" filter doesn't.

You have to switch from Mako's "|n" to Jinja2's "|safe" (this filter means "don't escape" - usually applied to things that return HTML).

  • http://docs.makotemplates.org/en/latest/filtering.html

  • http://jinja.pocoo.org/docs/dev/templates/#working-with-automatic-escaping

If you are not using it in your template, it is probably in your base header!

We had a line

${_debug or ''|n}

in there which should read

${_debug or ''|safe}

for Odoo.

0
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
Can anyone confirm that webkit reports are working on v8?
v8 webkit webkit_report
Avatar
0
Mar 15
4150
<type 'exceptions.TypeError'>,coercing to Unicode: need string or buffer, bool found,<traceback object at 0x05E61C88> Solved
webkit webkit_report
Avatar
Avatar
Avatar
Avatar
4
Dec 20
10400
Webkit report with OpenERP 7 Inherited fields of module are not displaying?
webkit webkit_report
Avatar
0
Mar 15
5008
Account Financial Report Webkit Module not working on Odoo Apps Store
webkit reports webkit_report
Avatar
Avatar
1
Oct 15
6113
Where is the webkit report editor?
v8 webkit editor
Avatar
0
Mar 15
4175
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة 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