What is an Odoo Wizard?
A wizard in Odoo is a popup window primarily used to perform user-defined actions. It operates using a Transient Model, which means the data it handles is stored temporarily and is automatically deleted from the database at regular intervals.
Steps to Create an Odoo Wizard Model
- Create the Model
Define the wizard model with the necessary fields in a .py file.
python
1from odoo import models, fields, api23class SaleOrderDiscountWizard(models.TransientModel):4 _name = 'sale.order.discount.wizard'5 _description = 'Apply Discount to Sale Orders'67 discount = fields.Float(string='Discount (%)', required=True)8 sale_order_ids = fields.Many2many(9 'sale.order',10 string='Sale Orders',11 required=True12 )1314 def apply_discount(self):15 for order in self.sale_order_ids:16 for line in order.order_line:17 line.discount = self.discount
Integrate the Wizard into the Module
- Update __init__.py
Include the .py file in the __init__.py of the models folder.
python
1from . import sale_order_discount_wizard
- Update __manifest__.py
Add the .xml file to the data section of the module's manifest.
python
1'data': [2 'views/sale_order_discount_wizard.xml',3],
Apply Changes
- Restart the Odoo server.
- Upgrade the custom module.
The wizard will now be accessible through the menu and will function as defined.



