Hello world. As i promise on this post How to Call Wizard from XML Button Odoo, i will share about wizard on Odoo. As you can see on previous post i just call wizard on the xml file. Now, i will share how to create wizard on Odoo. You know, wizard on Odoo is like pop up when in website, so in wizard data will save in memory, not in database Odoo. Usually we show wizard is for input additional data. So lets do it.
On this post, i just share wizard, if you want call wizard, you can read on this post How to Call Wizard From XML Button Odoo. So you can on my wizard.xml file bellow.
<?xml version="1.0" encoding="utf-8"?> <openerp> <data> <record id="dedy_yuristiawan_wiz" model="ir.ui.view"> <field name="name">dedy.yuristiawan.wizard.name</field> <field name="model">dedy.yuristiawan.wizard</field> <field name="arch" type="xml"> <form string="Hi i am wizard"> <group> <field name="name"/> </group> <footer> <button name="create_request" string="Finished" type="object" class="btn-primary"/> <button string="Cancel" class="btn-default" special="cancel" /> </footer> </form> </field> </record> <record id="action_view_wizard" model="ir.actions.act_window"> <field name="name">Hi i am a wizard</field> <field name="type">ir.actions.act_window</field> <field name="res_model">dedy.yuristiawan.wizard</field> <field name="view_type">form</field> <field name="view_mode">form</field> <field name="view_id" ref="dedy_yuristiawan_wiz"/> <field name="target">new</field> </record> </data> </openerp>
Ass you can see, just 2 record on my xml file. On the bottom record i have name, type, model, view type, view mode, view_id, and target. The important is :
1. Type ir.actions.act_window it mean will show window like from view usually.
2. Res_model dedy.yuristiawan.wizard it's my model.
3. Target new it will show as new form, you can set current, it mean will show your current form.
4. View Id dedy_yuristiawan_wiz it will call top record as you can see. You know Odoo its run from Top to Bottom, That's why i put dedy_yuristiawan_wiz on the top (it mean, i make declaration first before i call it).
5. On the Top record at it look like similar with bottom record, i just add field, that i create on python file, and two button, button Cancel will dismiss this wizard and button Finish will call function create_request on my python file.
And this one, i call it python file.
from openerp import models, fields, api, _ from openerp.exceptions import UserError, ValidationError, Warning class DedyYuristiawan(models.TransientModel): _name = "dedy.yuristiawan.wizard" name = fields.Char('Name', required=True) @api.multi def create_request(self): print "You click finish" return True
As you can see, the class have name models.TransientModel it mean wizard. And then i create field name that i call in my xml file <field name="name"/> . Last i create function def create_request(self). That's i told you before, if want to call this function i create button Finish with this syntax <button name="create_request" string="Finished" type="object" button with name and type object.
That's it. So if want make wizard you can read first, you can create code python first and then xml code. Aha i forget something, Usually these file (python and xml) i put on folder Wizard, and the i declare on the __init__.py with include python file and then on __openerp__.py with this 'wizard/split_wo_wizard.xml' put on the top.
It real that's it. Aha. Just read first, if you still confuse about my code, you can write comment bellow. Thanks.
Wow.. Greate... Simple..Thanks..
ReplyDeletecan you add more tutorials about Odoo..plzz..
Great example
ReplyDeleteThanks
Simple and Good.
ReplyDeleteIt makes people to understand easily.
This comment has been removed by the author.
ReplyDeletegreate its simple to easy
ReplyDeletegreat.......
ReplyDeletei have a question..
how to display the selected records in the tree view(checked) to be displayed in the wizard tree view
This comment has been removed by the author.
ReplyDeletei am following your tutorials because your tutorials has step by step implementation and easy to understand. Thanks a lot buddy.
ReplyDeleteVery nice! Please give us more tutorials like this.)
ReplyDeletehey i have a question anybody give me answer i have a many wizard in wizard so how can save data of wizard in tree view
ReplyDelete