Base Print Wizard
Provides a reusable base wizard for printing reports from any Odoo model.
Key features:
Dynamic report list - wizard auto-discovers all ir.actions.report records flagged show_in_wizard = True for the active model.
Domain filtering - each report can define a domain_form so it only appears when every selected record matches the domain (e.g. only confirmed orders).
Access-aware and validated - reports respect their configured groups, and the selected report is validated again on the server before printing.
Auto-select - when exactly one report qualifies, it is pre-selected and the user can print immediately without choosing.
Extensible - subclass base.print.wizard to add extra fields (print mode, date range, etc.) and override _get_report_context() to pass context to the report.
Optional copy options - inherit base.print.copy.mixin when a specialized wizard needs copy quantity and Original/Copy type fields.
Use Pattern 1 (direct binding) when you only need to choose among multiple reports. Use Pattern 2 (subclass) when the wizard itself needs extra options that influence how the report renders. The copy mixin is optional and does not add fields to the base wizard. See USAGE.md for step-by-step instructions.
Table of contents
Usage
Pattern 1 - Use wizard directly (no Python subclass)
Best for: multiple reports on one model, wizard just picks which to print.
Step 1: Mark reports with show_in_wizard = True (Technical menu → Reporting → Reports, or via XML data)
<record id="action_report_my_document" model="ir.actions.report">
<field name="show_in_wizard" eval="True" />
<!-- optional: only show when every selected record matches this domain -->
<field name="domain_form">[('state', '=', 'confirm')]</field>
</record>
Step 2: Bind a window action to the source model
<record id="action_open_my_print_wizard" model="ir.actions.act_window">
<field name="name">Print Report</field>
<field name="res_model">base.print.wizard</field>
<field name="view_mode">form</field>
<field name="view_id" ref="base_print_wizard.view_print_wizard_base" />
<field name="binding_model_id" ref="my_module.model_my_document" />
<field name="binding_view_types">list,form</field>
<field name="binding_type">report</field>
<field name="target">new</field>
</record>
The wizard lists all reports flagged show_in_wizard = True for that model. If domain_form is set, the report only appears when every active record matches the domain. Reports restricted to groups are only shown to users in one of those groups. When only one report qualifies, it is auto-selected and the user can click Print immediately.
Pattern 2 - Subclass for extra wizard fields
Best for: single fixed report with extra options (e.g. print mode, date range).
The fixed report must still have show_in_wizard = True, use the same model as the active records, and satisfy its domain_form when one is configured.
Step 1: Create a child TransientModel
from odoo import api, fields, models
class MyDocumentPrintWizard(models.TransientModel):
_name = "my.document.print.wizard"
_inherit = "base.print.wizard"
_description = "My Document Print Wizard"
print_mode = fields.Selection(
selection=[("summary", "Summary"), ("detail", "Detail")],
default="summary",
required=True,
)
@api.model
def _get_doctype_default(self):
# Pin the default selection. The report must still be available for the records.
return self.env.ref("my_module.action_report_my_document")
def _get_report_context(self):
res = super()._get_report_context()
res["print_mode"] = self.print_mode
return res
Step 2: Extend the base view to show the extra field
<record id="view_my_document_print_wizard_form" model="ir.ui.view">
<field name="name">my.document.print.wizard.form</field>
<field name="model">my.document.print.wizard</field>
<field name="inherit_id" ref="base_print_wizard.view_print_wizard_base" />
<field name="mode">primary</field>
<field name="arch" type="xml">
<!-- Replace doctype field with your custom field -->
<field name="doctype" position="replace">
<field name="doctype" invisible="1" />
<field name="print_mode" widget="radio" />
</field>
</field>
</record>
Step 3: Bind the window action to the child wizard
<record id="action_my_document_print_wizard" model="ir.actions.act_window">
<field name="name">Print Report</field>
<field name="res_model">my.document.print.wizard</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_my_document_print_wizard_form" />
<field name="binding_model_id" ref="my_module.model_my_document" />
<field name="binding_view_types">list,form</field>
<field name="binding_type">report</field>
<field name="target">new</field>
</record>
Module dependency
Add base_print_wizard to your module’s depends list:
"depends": ["base_print_wizard"],
Optional copy options
Add the copy fields only to wizards that need them by inheriting the optional mixin:
from odoo import models
class MyDocumentPrintWizard(models.TransientModel):
_name = "my.document.print.wizard"
_inherit = ["base.print.wizard", "base.print.copy.mixin"]
def _get_report_context(self):
res = super()._get_report_context()
res.update(self._get_copy_report_context())
return res
Add copy_qty and copy_type to the specialized wizard view. The mixin validates that the copy quantity is greater than zero, but does not add fields to the base wizard view.
<record id="view_my_document_print_wizard_form" model="ir.ui.view">
<field name="name">my.document.print.wizard.form</field>
<field name="model">my.document.print.wizard</field>
<field name="inherit_id" ref="base_print_wizard.view_print_wizard_base" />
<field name="mode">primary</field>
<field name="arch" type="xml">
<xpath expr="//group[@name='criteria']/group[last()]" position="inside">
<field name="copy_qty" />
<field name="copy_type" />
</xpath>
</field>
</record>
Validation behavior
A report must have show_in_wizard = True and its model must match the active model.
Every selected record must match domain_form; mixed selections do not expose a partially applicable report.
Reports restricted with groups_id are only available to members of those groups.
domain_form syntax is validated when the report action is saved.
The selected report is validated again by action_print() to prevent bypassing the form-view domain through RPC or custom code.
Override reference
Method |
When to override |
|---|---|
_get_doctype_default() |
Fix a single default report instead of auto-select |
_get_available_report_ids() |
Custom report filtering logic |
_get_action_report() |
Change which records are passed to the report |
_get_report_context() |
Pass extra context to report_action() |
_validate_report() |
Add server-side report validation rules |
Bug Tracker
Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed feedback.
Do not contact contributors directly about support or help with technical issues.
Credits
Contributors
Saran Lim. <saranl@ecosoft.co.th>
Maintainers
Current maintainer:
This module is part of the ecosoft-odoo/ecosoft-addons project on GitHub.
You are welcome to contribute.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file odoo_addon_base_print_wizard-18.0.1.1.0-py3-none-any.whl.
File metadata
- Download URL: odoo_addon_base_print_wizard-18.0.1.1.0-py3-none-any.whl
- Upload date:
- Size: 31.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
17e75e378349593a23a3a5097b902c7ffb21839eaeb59cb22919c607c9e827d1
|
|
| MD5 |
f38bf36fd98434f112e54e5f71be53a0
|
|
| BLAKE2b-256 |
1925b1febf9c888bbecef3c829f1551ba306dfc016096e7ed11a3203ee62eb3d
|