Status Bar In Odoo 14
STATUS BAR IN ODOO
A status bar is a horizontal window at the bottom of a parent window in which an application can display various kinds of status information. The status bar can be divided into parts to display more than one type of information.
Status bar will be shown on top of the Form . It is for showing the status of the current record.
- For defining this we need to add a Selection Field inside the python file with some values.
- Then we have define that field in the header of the form with “widget=’statusbar'”
*: First you need to create py file in directory model.
eg:class <ClassName>(models.Model):
_name=”class.name”
state = fields.Selection([
(‘draft’, ‘Draft’),
(‘approved’, ‘Approved’),
(‘done’, ‘Done’),
(‘cancel’, ‘Cancelled’),
], string=’Status’, index=True, readonly=True, default=’draft’)
3.Create corresponding xml file
eg:<record id=”create_wizard_form” model=”ir.ui.view”>
<field name=”name”>New Wizard</field>
<field name=”model”>odoo.wizard</field>
<field name=”arch” type=”xml”>
<form string=”Wizard Details”>
<group>
<field name=”state” widget=”statusbar”/>
</group>
</form>
</field>
</record>
Mandatory to add xml in __manifest__.py file
The print will be like this:
ADDING STATUS BAR BY INHERITANCE
Step 1: you have to inherit the class as you want the status bar
eg: class SaleOrder(models.Model):
_inherit=’sale.order’ and add one Char field name as state
state = fields.Selection([ ('draft', 'Draft'), ('approved', 'Approved'), ('done', 'Done'), ('cancel', 'Cancelled'), ], string='Status', index=True, readonly=True, default='draft')
Step 2: Then you can create the corresponding xml add this code,
add that fields using record
<field name="state" widget="statusbar"/>