I have two user hr_manager and employees,I want to show a menu badge for passport request of HR Employees .In HR Managers Passport request Menu should show how many passport request will come from the employees . (Like How to show approval of leave request in existing odoo feature).How to implement this feature?Below is my code .
Now i can get the menu badge with static number 20 in the Passport request menu .From the below code..
def _needaction_count(self, domain=None):
#Here How to check the count of passport request
return 20 #But this number should come from the based on the request .
.py file==============================================
class hr_passport(osv.osv):
_name = 'hr.passport'
_inherit = ['ir.needaction_mixin']
_columns = {
'name':fields.many2one('hr.employee','Name',required=True),
'state': fields.selection([('draft', 'To Submit'), ('reject', 'Rejected'), ('validate_hr', 'HR Approved'),('validate_mgr','Manager Approved')],'State'),
'description':fields.char('Subject',required=True),
'date_issue':fields.date('Date'),
'details':fields.text('Details',required=True),
'remarks':fields.text('Remarks')
}
_defaults={
'state':lambda *a: 'draft',
'date_issue': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
'name': lambda s, cr, uid, c: uid,
}
def action_button_reject(self,cr,uid,ids,context=None):
self.write(cr,uid,ids,{'state':'reject'})
return True
def action_button_manager(self,cr,uid,ids,context=None):
self.write(cr,uid,ids,{'state':'validate_mgr'})
return True
@api.model
def _needaction_domain_get(self):
if self.env.user.name == "user1@gmail.com":
return False #
return [('state', '=', 'draft')]
@api.model
def _needaction_count(self, domain=None):
#Here How to check the count of passport request
return 20 # How to add the number of count request of a
hr_passport()
.xml file======================
<record model="ir.ui.view" id="hrpassport_tree_view">
<field name="name">hr.passport.tree</field>
<field name="model">hr.passport</field>
<field name="arch" type="xml">
<tree string="passport Details">
<field name="description"/>
<field name="date_issue"/>
<field name="details"/>
<field name="state"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="hrpassport_form">
<field name="name">hr.general.form</field>
<field name="model">hr.passport</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Passport Setails" version="7.0">
<header>
<button name="action_button_manager" class="oe_highlight" states="draft" string="Manager Approval" type="object" groups="base.group_hr_user"/>
<button name="action_button_reject" string="Reject" type="object" groups="base.group_hr_user"/>
<button name="action_button_validate" states="validate_mgr" class="oe_highlight" string="HR Approval" type="object" groups="base.group_hr_user"/>
<button name="action_button_draft" string="Reset to Draft" type="object" groups="base.group_hr_user"/>
<field name="state" widget="statusbar" statusbar_visible="draft,reject,validate_hr,validate_mgr" statusbar_colors='{"draft":"blue","reject":"blue","validate_hr":"blue","validate_mgr":"blue"}'/>
</header>
<sheet>
<group>
<field name="name"/>
<field name="description"/>
<field name="date_issue"/>
<field name="details"/>
<field name="remarks"/></group>
</sheet>
</form>
</field>
</record>
<record model="ir.actions.act_window" id="action_passport_view">
<field name="name">Passport Request</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">hr.passport</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<menuitem id="hr_general_request" name="General Request" parent="hr.menu_hr_root" />
<menuitem id="hr_general_passport" name="Passport request" parent="hr_general_request" action="action_passport_view" />
=============I referd below link but ,I am confused which portion I can apply this feature in my module---
http://ludwiktrammer.github.io/odoo/odoo-count-badge-menu-notification.html
Any information / help / details are very welcome!
Thanks......