ODOO
Buttons
On this step we will explain button's types in odoo , there are many types of buttons in odoo just as :
- object buttons : this type of button is created to call python function
- action buttons : this type of button is created to call view " to open new view when the user click it'
- Smart button : actually it's action button but beside open new view it also used to show some information about some objects "we show some fields with this button
Now let us give an examples to create any type of buttons
_ object button : let us say that we have a function by name "get_operation_start" and we want to call this function by click on some button , so we can make that button inside our view just as bellow
<button name="get_operation_start" type="object" string="Start" class="oe_highlight" />
to explain what we did :
name="" here we pass the name of the function that we want to call when we click on this button
type="" here we defined the type of this button 'object or action'
string="" here we defined the label for this button
class="" here we defined the class for this button
_ action button : we can define it as bellow
<button name="module_name.view_button_action" icon="fa-check" type="action" string="Graduated Students" />
now we have to create view_button_action which will call some view as bellow
@api.multi
def view_button_action(self):
return {
'name': _('ModelName'),
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'model.model',
'view_id': False,
'type': 'ir.actions.act_window',
'domain': [],
}
'name': _('ModelName'),
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'model.model',
'view_id': False,
'type': 'ir.actions.act_window',
'domain': [],
}
_ smart button : smart button is that button which contain some fields which are display with this button , and for example we can give the smart button that show the available quantity of the product in the stock which is defined as bellow
<button class="oe_stat_button"
name="product_open_quants"
icon="fa-building-o"
type="object" attrs="{'invisible':[('type', '!=', 'product')]}">
<field name="qty_available" widget="statinfo" string="On Hand"/></button>
name="product_open_quants"
icon="fa-building-o"
type="object" attrs="{'invisible':[('type', '!=', 'product')]}">
<field name="qty_available" widget="statinfo" string="On Hand"/></button>
No comments:
Post a Comment