What is wizard.what are the uses or application with example
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Comptabilitat
- Inventari
- PoS
- Project
- MRP
This question has been flagged
please refer these documentation.It will help you
https://www.odoo.com/documentation/12.0/howtos/backend.html#wizards
Hi,
Geo,
* Odoo Wizard Document Link Given Below Please refer It will definitely help you. : https://www.odoo.com/documentation/12.0/howtos/backend.html#wizards
* Wizard Example:
1. Create the Transient Model : I have create a new python file salewiz.py under the models directory. The name of our transient model is : sale.control.limit.wizard. For now, we won’t bother creating fields for it. Let’s keep it basic.
# -*- coding: utf-8 -*-
from odoo import api, models,fields
from odoo.exceptions import UserError
from odoo import exceptions
import logging
_logger = logging.getLogger(__name__)
class SaleConfirmLimit(models.TransientModel):
_name='sale.control.limit.wizard'
invoice_amount = fields.Float('Invoice Amount',readonly=1)
new_balance = fields.Float('Total Balance',readonly=1)
my_credit_limit = fields.Float('Partner Credit Limit',readonly=1)
@api.multi
def agent_exceed_limit(self):
_logger.debug(' \n\n \t We can do some actions here\n\n\n')
2. Create the XML view file for the Wizard or popup window
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record model="ir.ui.view" id="my_credit_limit_wizard">
<field name="name">Confirming Sale Order When Credit is Over Limit</field>
<field name="model">sale.control.limit.wizard</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form>
<group>
<span>The following customer is about or exceeded their credit limit. This operation needs an Authorized Employee to approve the sale order:</span>
</group>
<group>
<field name="invoice_amount" widget="monetary"/>
<field name="new_balance" widget="monetary"/>
<field name="my_credit_limit" widget="monetary"/>
</group>
<footer>
<button string="Cancel" special="cancel" class="oe_highlight"/>
<button name="agent_exceed_limit" string="Request Manager to Approve Sale" type="object" class="oe_highlight" />
</footer>
</form>
</field>
</record>
</odoo>
3. Update the __manifest__.py file to edit the data attribute
'data': [
'views/partner_credit_view.xml',
'views/wizard.confirm.overcredit.xml',
],
4. We may need to create the view with its parameter values !
params=order.check_credit_limit()
view_id=self.env['sale.control.limit.wizard']
new = view_id.create(params[0])
#The part of the code to initiate the creation of the wizard is shown below:return {
'type': 'ir.actions.act_window',
'name': 'Warning : Customer is about or exceeded their credit limit',
'res_model': 'sale.control.limit.wizard',
'view_type': 'form',
'view_mode': 'form',
'res_id' : new.id,
'view_id': self.env.ref('control_credit_limit.my_credit_limit_wizard',False).id,
'target': 'new',
}
5. As we have extended the sale.order class and we are to override the action_confirm method, we need to return the object to fire off the popup window as follows !
# -*- coding: utf-8 -*-
from odoo import api, models,fields
class MySale(models.Model):
_inherit = "sale.order"
@api.one
def check_credit_limit(self):
partner=self.partner_id
new_balance=self.amount_total+partner.credit
if new_balance>partner.my_credit_limit:
params = {'invoice_amount':self.amount_total,'new_balance': new_balance,'my_credit_limit': partner.my_credit_limit}
return params
else:
return True
@api.multi
def action_confirm(self):
for order in self:
params=order.check_credit_limit()
view_id=self.env['sale.control.limit.wizard']
new = view_id.create(params[0])
return {
'type': 'ir.actions.act_window',
'name': 'Warning : Customer is about or exceeded their credit limit',
'res_model': 'sale.control.limit.wizard',
'view_type': 'form',
'view_mode': 'form',
'res_id' : new.id,
'view_id': self.env.ref('control_credit_limit.my_credit_limit_wizard',False).id,
'target': 'new'}
#res = super(MySale, self).action_confirm()
#return res
6. That’s it! we have created a simple wizard popup window.
Thank You.
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Registrar-seRelated Posts | Respostes | Vistes | Activitat | |
---|---|---|---|---|
|
1
de des. 22
|
3152 | ||
|
4
de jul. 25
|
4736 | ||
|
2
de des. 23
|
17480 | ||
|
6
d’abr. 18
|
21111 | ||
|
5
de des. 23
|
18068 |
hello,
please refer this link, i hope this will helps you.: https://odooforbeginnersblog.wordpress.com/2017/03/05/how-to-create-wizards-in-odoo/