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

Custom code: odoo19 pdf report ValueError: External ID not found in the system

Subscribe

Get notified when there's activity on this post

This question has been flagged
odooodoo19pdf reports
3 Replies
1116 Views
Avatar
Arjun Baidya

def monthly_attendance_pdf_report(self):
days_of_month = self.get_days_of_month(self.date_from, self.date_to)
datas = self.monthly_all_employee_attendance_generate()
employees_attendances = datas.get('attendance_details', [])
company = self.company
grouped_attendance_details = defaultdict(list)
for attendance in employees_attendances:
department = attendance.get('department', 'No Department')
grouped_attendance_details[department].append(attendance)
company_data = {
'company_name': company.name,
'company_street': company.street or '',
'company_street2': company.street2 or '',
'company_city': company.city or '',
'company_country': company.country_id.name or '',
'date_from': self.date_from.strftime('%B - %Y'),
'date_to': self.date_to.strftime('%Y-%m-%d'),
}
return self.env.ref('module_name.action_monthly_attendance_pdf_report').report_action(None, data={'attendance_details': grouped_attendance_details, 'days_of_month': days_of_month, 'company_data': company_data})

<report
id="action_monthly_attendance_pdf_report"
model="monthly.employee.attendance.wizard"
string="monthly_attendance_report"
report_type="qweb-pdf"
name="module_name.report_monthly_all_emp_attendance"
file="module_name.report_monthly_all_emp_attendance"
paperformat="module_name.corporate_standard_attendance_format"
print_report_name="monthly_attendance_Report"
/>


I use this code but shows error

 return self.env.ref('hr_reports.action_monthly_attendance_pdf_report').report_action(None, data={'attendance_details': grouped_attendance_details, 'days_of_month': days_of_month, 'company_data': company_data})
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/arjun/odoo_dev/odoo19/odoo/odoo/orm/environments.py", line 166, in ref
    res_model, res_id = self['ir.model.data']._xmlid_to_res_model_res_id(
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/arjun/odoo_dev/odoo19/odoo/odoo/addons/base/models/ir_model.py", line 2232, in _xmlid_to_res_model_res_id
    return self._xmlid_lookup(xmlid)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/arjun/odoo_dev/odoo19/odoo/odoo/tools/cache.py", line 98, in lookup
    return self.lookup(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/arjun/odoo_dev/odoo19/odoo/odoo/tools/cache.py", line 155, in lookup
    value = self.method(*args, **kwargs)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/arjun/odoo_dev/odoo19/odoo/odoo/addons/base/models/ir_model.py", line 2225, in _xmlid_lookup
    raise ValueError('External ID not found in the system: %s' % xmlid)
ValueError: External ID not found in the system: hr_reports.action_monthly_attendance_pdf_report


Why it shows this error in odoo19 ?

0
Avatar
Discard
Avatar
Codesphere Tech
Best Answer

Hello Arjun,
Reference from Odoo 19 default:

<record id="action_account_original_vendor_bill" model="ir.actions.report">

            <field name="name">Original Bills</field>

            <field name="model">account.move</field>

            <field name="binding_model_id" ref="model_account_move"/>

            <field name="report_type">qweb-pdf</field>

            <field name="report_name">account.report_original_vendor_bill</field>

            <field name="report_file">account.report_original_vendor_bill</field>

            <field name="attachment">'original_vendor_bill.pdf'</field>

            <field name="attachment_use">True</field>

            <field name="domain" eval="[('move_type', 'in', ('in_invoice', 'in_refund', 'in_receipt')), ('message_main_attachment_id', '!=', False)]"/>

        </record>

Hope it is helpful.

0
Avatar
Discard
Avatar
Marvin Accuweb.Cloud
Best Answer


Hi @Arjun Baidya,

The error appears because Odoo cannot find the report record in its internal database (ir.model.data). This usually means the report XML file wasn’t properly loaded during installation or update.

Please check the following points:

  1. Ensure your report definition is properly wrapped within <odoo> and </odoo> tags.
  2. Confirm that your report XML file (for example, report_monthly_attendance.xml) is included inside the data section of your module’s manifest file, not under demo.
  3. After updating the manifest, upgrade your module using the Odoo update command to reload all XML files and register the report again.
  4. You can also upgrade it from the Odoo interface by going to Apps → Upgrade hr_reports.
  5. If the issue continues, open the Odoo shell and check whether the report ID exists in the system. If it’s missing, that means the XML file still hasn’t been loaded correctly.

Once the XML file is properly loaded and the module has been upgraded, Odoo will be able to locate hr_reports.action_monthly_attendance_pdf_report, and the PDF report will generate without any issue.




0
Avatar
Discard
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Best Answer

Hi,


The error occurs because Odoo cannot find the XML ID hr_reports.action_monthly_attendance_pdf_report.

You defined the report in your custom module, not hr_reports.

The correct reference is module_name.action_monthly_attendance_pdf_report.

Ensure the <report> XML is included in the data section of __manifest__.py.

Use self.env.ref('module_name.action_monthly_attendance_pdf_report') in your method.

Make sure the module is installed and the XML file is loaded.

Update the module

After these steps, Odoo will find the XML ID and generate the report without error.


Hope it helps.

0
Avatar
Discard
Arjun Baidya
Author

Hello,
Thanks for your comment.
But my module name is hr_reports so hr_reports.action_monthly_attendance_pdf_report
in below i given code again
class MonthlyAllEmployeeAttendanceShow(models.TransientModel):
_name = 'monthly.employee.attendance.wizard'

def monthly_attendance_pdf_report(self):
days_of_month = self.get_days_of_month(self.date_from, self.date_to)
datas = self.monthly_all_employee_attendance_generate()
employees_attendances = datas.get('attendance_details', [])
company = self.company
grouped_attendance_details = defaultdict(list)
for attendance in employees_attendances:
department = attendance.get('department', 'No Department')
grouped_attendance_details[department].append(attendance)
company_data = {
'company_name': company.name,
'company_street': company.street or '',
'company_street2': company.street2 or '',
'company_city': company.city or '',
'company_country': company.country_id.name or '',
'date_from': self.date_from.strftime('%B - %Y'),
'date_to': self.date_to.strftime('%Y-%m-%d'),
}
return self.env.ref('hr_reports.action_monthly_attendance_pdf_report').report_action(None, data={'attendance_details': grouped_attendance_details, 'days_of_month': days_of_month, 'company_data': company_data})

report.xml
<report
id="action_monthly_attendance_pdf_report"
model="monthly.employee.attendance.wizard"
string="monthly_attendance_report"
report_type="qweb-pdf"
name="hr_reports.report_monthly_all_emp_attendance"
file="hr_reports.report_monthly_all_emp_attendance"
paperformat="hr_reports.corporate_standard_attendance_format"
print_report_name="monthly_attendance_Report"
/>

template file
some portion code
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<template id="report_monthly_all_emp_attendance">
<t t-call="web.html_container">
<t t-call="web.internal_layout">
<div class="page" style="padding-top:10px;">
<div class="row">
<div class="col-xs-12">
<div class="company-info text-center" style="line-height: 1;">
<p style="line-height: 0.5;">
<b>
<t t-esc="company_data['company_name']"/>
</b>
</p>
<p style="line-height: 0.5;">
<t t-esc="company_data['company_street']"/>,
<t t-esc="company_data['company_street2']"/>,
<t t-esc="company_data['company_city']"/>,
<t t-esc="company_data['company_country']"/>
</p>
<p style="line-height: 0.5;">
<b>Attendance for the month of:</b>
<t t-esc="company_data['date_from']"/>
</p>
</div>

so where is the probem?
in my menifest file all file I added

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
Odoo 19 online: images won´t print on pdf reports
ImageList odoo19 Online pdf reports
Avatar
Avatar
Avatar
2
Oct 25
520
SOC 1 Report
odoo
Avatar
Avatar
2
Nov 25
294
邮箱无法正常使用
odoo
Avatar
Avatar
1
Nov 25
2246
Return Process in Odoo 19 EE
deliveryorder returns return_products odoo odoo19
Avatar
Avatar
1
Nov 25
231
How do I go about this error? I am trying to uninstall a module
odoo
Avatar
Avatar
1
Nov 25
3486
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