Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to Show a menu badge in Odoo HR custom module

By
Odoo
on 5/18/15, 3:10 AM 741 views

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......

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 5/18/15, 3:10 AM
Seen: 741 times
Last updated: 5/19/15, 5:17 AM