Reason for not getting the default filter Approved when in the menu item Approved Applications
There are multiple search views for defaultly selecting the filters SUBMIT and APPROVE in 2 different menus..
I am getting SUBMIT as default filter in its corresponding menu 'Applications Submitted' but not getting Approved default filter in Approved Applications
My model is:-
#Model of Admission
class Admission(models.Model):
_name = 'student.admission'
_rec_name='fname'
fname = fields.Char(string = 'First Name', required = True)
lname = fields.Char(string = 'Last Name', required = True)
student_dob = fields.Date(string = "Date of Birth")
age = fields.Integer(string = 'Age')
admission_class=fields.Selection([('lkg','LKG'),
('ukg','UKG'),
('firststd','First Standard')],
string='Admission Class',required = True)
photo = fields.Binary(string = 'Image')
gender = fields.Selection([('male', 'Male'),
('female', 'Female'),
('others', 'Others')],
string = 'Gender')
place = fields.Char(string = 'Place', required = True)
#hide_inv_button = fields.Boolean(copy = False, default = True)
pincode = fields.Integer(string = 'PinCode',required=True)
nationality = fields.Many2one('res.country', string = 'Nationality')
Residence_phoneno =fields.Char(string='Residence Phone Number',required =True)
Mothers_name =fields.Char(string='Mothers Name',required=True)
Mothers_qualification=fields.Char(string='Mothers Qualificatioin')
Fathers_name=fields.Char(string='Fathers Name')
Fathers_qualification=fields.Char(string='Fathers Qualification')
have_sibling=fields.Boolean(string='Have any Sibling in this school')
sibling_name=fields.Char(string='Sibling name',default=False)
state = fields.Selection([
('draft', 'Draft'),
('in_progress', 'In Progress'),
('done', 'Done'),
('approved', 'Approve')],
default = 'draft')
@api.multi
def action_confirmed(self):
self.ensure_one()
self.write({'state': 'in_progress'})
@api.multi
def action_finished(self):
self.ensure_one()
self.write({'state': 'done'})
#Method of Approve Button
@api.multi
def action_approve(self):
self.ensure_one()
self.write({'state': 'approved'})
My View is:-
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
<!-- Tree View of Student Admission -->
<record id="view_tree_admission" model="ir.ui.view">
<field name="name">Admission</field>
<field name="model">student.admission</field>
<field name="arch" type="xml">
<tree>
<field name="fname"/>
<field name="lname"/>
<field name="student_dob"/>
<field name="admission_class"/>
</tree>
</field>
</record>
<!-- Search View of Admission -->
<record id="view_admission_search" model="ir.ui.view">
<field name="name">student.admission.search</field>
<field name="model">student.admission</field>
<field name="arch" type="xml">
<search string="Admission Information">
<group col="10" colspan="4">
<field name="fname" />
<field name="admission_class" />
<field name="nationality" />
</group>
</search>
</field>
</record>
<!-- Form View of Admission -->
<record model="ir.ui.view" id="admission_form_view">
<field name="name">student.admission.form</field>
<field name="model">student.admission</field>
<field name="arch" type="xml">
<form string="Admission Form">
<header>
<button string="Confirm"
type = "object"
name = "action_confirmed"
class = "oe_highlight"
attrs = "{'invisible': ['|',('state', '=', 'in_progress'),'|', ('state','=', 'done'),('state','=','approved')]}"/>
<button string="Submit"
type = "object"
name = "action_finished"
attrs = "{'invisible': ['|',('state', '=', 'draft'),'|',('state','=', 'approved'),('state', '=','done')]}"/>
<button name="action_approve" string="Approve" type="object" class="oe_highlight"
attrs="{'invisible': ['|',('state', '=', 'approved'),'|',('state', '=', 'in_progress'),('state','=','draft')]}"
groups ='school.school_group_admin'/>
<field name="state" widget = "statusbar"/>
</header>
<sheet>
<p style="text-align:center"><strong>****Application Form****</strong></p>
<field name="photo" widget="image" class="oe_left oe_avatar"/>
<group>
<field name="fname"/>
<field name="lname"/>
<field name="student_dob"/>
<field name="age"/>
<field name="admission_class"/>
<field name="place"/>
<field name="pincode"/>
<field name="nationality"/>
<field name="Residence_phoneno"/>
<field name="Mothers_name"/>
<field name="Mothers_qualification"/>
<field name="Fathers_name"/>
<field name="Fathers_qualification"/>
<field name="have_sibling"/>
<field name="sibling_name" attrs="{'invisible': [('have_sibling', '=', False)]}"/>
</group>
</sheet>
</form>
</field>
</record>
<!-- Search View of Admission Submit -->
<record id="view_search_studentadmission" model="ir.ui.view">
<field name="name">Admission.tree</field>
<field name="model">student.admission</field>
<field name="arch" type="xml">
<search string="Admission Submit Search">
<field name="state"/>
<filter name="SUBMIT" string="SUBMIT" domain="[('state', 'ilike', 'done')]"/>
</search>
</field>
</record>
<!-- Search View of Admission Approved -->
<record id="view_search_studentadmissionapproval" model="ir.ui.view">
<field name="name">Admission.tree</field>
<field name="model">student.admission</field>
<field name="arch" type="xml">
<search string="Admission Approved Search">
<field name="state"/>
<filter name="APPROVED" string="APPROVED" domain="[('state', 'ilike', 'approved')]"/>
</search>
</field>
</record>
<!-- Generic View Admission -->
<record id="admission_menu_action" model="ir.actions.act_window">
<field name="name">Admission</field>
<field name="res_model">student.admission</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[]</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">Admission Form
</p>
</field>
</record>
<!-- Generic View Admission Submit -->
<record id="admission_submit_menu_action" model="ir.actions.act_window">
<field name="name">Admission Submit</field>
<field name="res_model">student.admission</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="context">{'search_default_SUBMIT': 1, 'default_SUBMIT': 'done'}</field>
<field name="domain">[]</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">Admissions Submitted
</p>
</field>
</record>
<!-- Generic View Admission Approved -->
<record id="admission_approved_menu_action" model="ir.actions.act_window">
<field name="name">Admission Approved</field>
<field name="res_model">student.admission</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="context">{'search_default_APPROVED': 1, 'default_APPROVED': 'approved'}
</field>
<field name="domain">[]</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">Admissions Approved
</p>
</field>
</record>
<menuitem id="school_admission_menu"
parent="school_menu"
name="Admission" sequence="4"/>
<menuitem id="school_student_admission_menu"
parent="school_admission_menu"
name="Application Form"
action="admission_menu_action"/>
<menuitem id="school_student_admission_submit_menu"
parent="school_admission_menu"
name="Applications Submitted"
action="admission_submit_menu_action"/>
<menuitem id="school_student_admission_approved_menu"
parent="school_admission_menu"
name="Approved Applications"
action="admission_approved_menu_action"
groups='school.school_group_admin'/>
</data>
</odoo>
Please Help
Thanks in Advance....