[IMP]: Convert buttons into stat buttons in hr modules
bzr revid: ypa@tinyerp.com-20140326120056-qqauj7pmhf0uxhuj
This commit is contained in:
parent
806e2fa2b3
commit
3897de56b7
|
@ -92,6 +92,17 @@ class hr_job(osv.Model):
|
|||
res.append(employee.job_id.id)
|
||||
return res
|
||||
|
||||
def _count_all(self, cr, uid, ids, field_name, arg, context=None):
|
||||
res = dict(map(lambda x: (x,{'documents_count': 0, 'application_count': 0,}), ids))
|
||||
try:
|
||||
for data in self.browse(cr, uid, ids, context=context):
|
||||
res[data.id] = {'documents_count': len(data.document_ids),
|
||||
'application_count': len(data.applicant_ids),
|
||||
}
|
||||
except:
|
||||
pass
|
||||
return res
|
||||
|
||||
_name = "hr.job"
|
||||
_description = "Job Position"
|
||||
_inherit = ['mail.thread', 'ir.needaction_mixin']
|
||||
|
@ -122,6 +133,10 @@ class hr_job(osv.Model):
|
|||
track_visibility='always',
|
||||
help="By default 'Closed', set it to 'In Recruitment' if recruitment process is going on for this job position."),
|
||||
'write_date': fields.datetime('Update Date', readonly=True),
|
||||
'applicant_ids':fields.one2many('hr.applicant', 'job_id', 'Applications'),
|
||||
'application_count': fields.function(_count_all, type='integer', string='Applications', multi=True),
|
||||
'document_ids': fields.one2many('ir.attachment', 'company_id', 'Documents'),
|
||||
'documents_count': fields.function(_count_all, type='integer', string='Documents', multi=True),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
|
@ -186,6 +201,20 @@ class hr_employee(osv.osv):
|
|||
|
||||
def _set_image(self, cr, uid, id, name, value, args, context=None):
|
||||
return self.write(cr, uid, [id], {'image': tools.image_resize_image_big(value)}, context=context)
|
||||
|
||||
def _count_all(self, cr, uid, ids, field_name, arg, context=None):
|
||||
res = dict(map(lambda x: (x,{'appraisal_count': 0, 'leaves_count': 0, 'contracts_count': 0, 'timesheet_count': 0, 'payslip_count': 0,}), ids))
|
||||
try:
|
||||
for datas in self.browse(cr, uid, ids, context=context):
|
||||
res[datas.id] = {'appraisal_count': len(datas.appraisal_ids),
|
||||
'leaves_count': len(datas.leave_ids),
|
||||
'contracts_count': len(datas.contract_ids),
|
||||
'timesheet_count': len(datas.timsheet_ids),
|
||||
'payslip_count': len(datas.payslip_ids)
|
||||
}
|
||||
except:
|
||||
pass
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
#we need a related field in order to be able to sort the employee by name
|
||||
|
@ -237,6 +266,16 @@ class hr_employee(osv.osv):
|
|||
'city': fields.related('address_id', 'city', type='char', string='City'),
|
||||
'login': fields.related('user_id', 'login', type='char', string='Login', readonly=1),
|
||||
'last_login': fields.related('user_id', 'date', type='datetime', string='Latest Connection', readonly=1),
|
||||
'appraisal_ids': fields.one2many('hr.evaluation.interview', 'user_to_review_id', 'Appraisal Interviews'),
|
||||
'leave_ids': fields.one2many('hr.holidays', 'employee_id', 'Leaves'),
|
||||
'contracts_ids': fields.one2many('hr.contract', 'employee_id', 'Contracts'),
|
||||
'timsheet_ids': fields.one2many('hr_timesheet_sheet.sheet', 'employee_id', 'Timesheets'),
|
||||
'payslip_ids': fields.one2many('hr.payslip', 'employee_id', 'Payslips'),
|
||||
'appraisal_count': fields.function(_count_all, type='integer', string='Appraisal Interviews', multi=True),
|
||||
'leaves_count': fields.function(_count_all, type='integer', string='Leaves', multi=True),
|
||||
'contracts_count': fields.function(_count_all, type='integer', string='Contracts', multi=True),
|
||||
'timesheet_count': fields.function(_count_all, type='integer', string='Timsheets', multi=True),
|
||||
'payslip_count': fields.function(_count_all, type='integer', string='Payslips', multi=True),
|
||||
}
|
||||
|
||||
def _get_default_image(self, cr, uid, context=None):
|
||||
|
|
|
@ -21,7 +21,13 @@
|
|||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<xpath expr="//div[@name='button_box']" position="inside">
|
||||
<button name="%(act_hr_employee_2_hr_contract)d" string="Contracts" type="action" groups="base.group_hr_manager"/>
|
||||
<button name="%(act_hr_employee_2_hr_contract)d"
|
||||
class="oe_stat_button"
|
||||
icon="fa-thumbs-o-up"
|
||||
type="action"
|
||||
groups="base.group_hr_manager">
|
||||
<field name="contracts_count" widget="statinfo" string="Contracts"/>
|
||||
</button>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='coach_id']" position="after">
|
||||
<field name="manager"/>
|
||||
|
|
|
@ -145,7 +145,12 @@
|
|||
</group>
|
||||
</xpath>
|
||||
<xpath expr="//div[@name='button_box']" position="inside">
|
||||
<button name="%(act_hr_employee_2_hr__evaluation_interview)d" string="Appraisal Interviews" type="action"/>
|
||||
<button name="%(act_hr_employee_2_hr__evaluation_interview)d"
|
||||
class="oe_stat_button"
|
||||
icon="fa-briefcase"
|
||||
type="action">
|
||||
<field name="appraisal_count" widget="statinfo" string="Appraisal Interviews"/>
|
||||
</button>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
|
|
@ -483,7 +483,13 @@
|
|||
</group>
|
||||
</xpath>
|
||||
<xpath expr="//div[@name='button_box']" position="inside">
|
||||
<button name="%(act_hr_employee_holiday_request)d" string="Leaves" type="action" groups="base.group_hr_user"/>
|
||||
<button name="%(act_hr_employee_holiday_request)d"
|
||||
type="action"
|
||||
class="oe_stat_button"
|
||||
icon="fa-calendar"
|
||||
groups="base.group_hr_user">
|
||||
<field name="leaves_count" widget="statinfo" string="Leaves"/>
|
||||
</button>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
|
|
@ -258,6 +258,15 @@ class hr_payslip(osv.osv):
|
|||
for r in res:
|
||||
result[r[0]].append(r[1])
|
||||
return result
|
||||
|
||||
def _count_detail_payslip(self, cr, uid, ids, field_name, arg, context=None):
|
||||
res = {}
|
||||
try:
|
||||
for details in self.browse(cr, uid, ids, context=context):
|
||||
res[details.id] = len(details.line_ids)
|
||||
except:
|
||||
pass
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
'struct_id': fields.many2one('hr.payroll.structure', 'Structure', readonly=True, states={'draft': [('readonly', False)]}, help='Defines the rules that have to be applied to this payslip, accordingly to the contract chosen. If you let empty the field contract, this field isn\'t mandatory anymore and thus the rules applied will be all the rules set on the structure of all contracts of the employee valid for the chosen period'),
|
||||
|
@ -287,6 +296,7 @@ class hr_payslip(osv.osv):
|
|||
'details_by_salary_rule_category': fields.function(_get_lines_salary_rule_category, method=True, type='one2many', relation='hr.payslip.line', string='Details by Salary Rule Category'),
|
||||
'credit_note': fields.boolean('Credit Note', help="Indicates this payslip has a refund of another", readonly=True, states={'draft': [('readonly', False)]}),
|
||||
'payslip_run_id': fields.many2one('hr.payslip.run', 'Payslip Batches', readonly=True, states={'draft': [('readonly', False)]}),
|
||||
'payslip_count': fields.function(_count_detail_payslip, type='integer', string="Payslip Computation Details"),
|
||||
}
|
||||
_defaults = {
|
||||
'date_from': lambda *a: time.strftime('%Y-%m-01'),
|
||||
|
|
|
@ -222,7 +222,12 @@
|
|||
</header>
|
||||
<sheet>
|
||||
<div class="oe_right oe_button_box">
|
||||
<button name="%(act_payslip_lines)d" string="Payslip Computation Details" type="action"/>
|
||||
<button name="%(act_payslip_lines)d"
|
||||
class="oe_stat_button"
|
||||
icon="fa-comment"
|
||||
type="action">
|
||||
<field name="payslip_count" widget="statinfo" string="Payslip Computation Details"/>
|
||||
</button>
|
||||
</div>
|
||||
<div class="oe_title">
|
||||
<label for="employee_id" class="oe_edit_only"/>
|
||||
|
@ -387,7 +392,13 @@
|
|||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<xpath expr="//div[@name='button_box']" position="inside">
|
||||
<button name="%(act_hr_employee_payslip_list)d" string="Payslips" type="action" groups="base.group_hr_user"/>
|
||||
<button name="%(act_hr_employee_payslip_list)d"
|
||||
class="oe_stat_button"
|
||||
icon="fa-money"
|
||||
type="action"
|
||||
groups="base.group_hr_user">
|
||||
<field name="payslip_count" widget="statinfo" string="Payslips"/>
|
||||
</button>
|
||||
</xpath>
|
||||
</data>
|
||||
</field>
|
||||
|
|
|
@ -74,16 +74,27 @@
|
|||
</header>
|
||||
<sheet>
|
||||
<div class="oe_right oe_button_box">
|
||||
<button name="action_makeMeeting" type="object"
|
||||
string="Schedule Meeting" help="Schedule interview with this applicant"/>
|
||||
<button name="%(survey.action_view_survey_question_message)d" type="action"
|
||||
<button name="action_makeMeeting" class="oe_stat_button" icon="fa-calendar" type="object"
|
||||
string="Schedule Meeting" help="Schedule interview with this applicant"/>
|
||||
<button name="%(survey.action_view_survey_question_message)d"
|
||||
class="oe_stat_button"
|
||||
icon="fa-pencil-square-o"
|
||||
type="action"
|
||||
string="Start Interview" help="Answer related job question"
|
||||
context="{'survey_id': survey, 'response_id': [response], 'response_no':0 ,'active' : response, 'object' : 'hr.applicant'}"
|
||||
attrs="{'invisible':[('survey','=',False)]}"/>
|
||||
<button name="action_print_survey" type="object"
|
||||
<button name="action_print_survey"
|
||||
class="oe_stat_button"
|
||||
icon="fa-pencil-square-o"
|
||||
type="object"
|
||||
string="Print Interview" help="Print interview report"
|
||||
attrs="{'invisible':[('survey','=',False)]}"/>
|
||||
<button name="action_get_attachment_tree_view" string="Documents" type="object"/>
|
||||
<button name="action_get_attachment_tree_view"
|
||||
class="oe_stat_button"
|
||||
icon="fa-pencil-square-o"
|
||||
type="object">
|
||||
<field name="attachment_number" widget="statinfo" string="Documents"/>
|
||||
</button>
|
||||
</div>
|
||||
<div class="oe_title">
|
||||
<label for="name" class="oe_edit_only"/>
|
||||
|
@ -367,10 +378,23 @@
|
|||
<xpath expr="//field[@name='department_id']" position="after">
|
||||
<field name="user_id" class="oe_inline"/>
|
||||
</xpath>
|
||||
<div name="buttons" position="inside">
|
||||
<button string="Applications" name="%(action_hr_job_applications)d" context="{'default_user_id': user_id}" type="action"/>
|
||||
<button string="Documents" name="action_get_attachment_tree_view" type="object"/>
|
||||
</div>
|
||||
<xpath expr="//div[@name='buttons']" position="inside">
|
||||
<div class="oe_button_box" >
|
||||
<button class="oe_stat_button"
|
||||
icon="fa-file-o"
|
||||
name="%(action_hr_job_applications)d"
|
||||
context="{'default_user_id': user_id}"
|
||||
type="action">
|
||||
<field name="application_count" widget="statinfo" string="Applications"/>
|
||||
</button>
|
||||
<button class="oe_stat_button"
|
||||
icon="fa-book"
|
||||
name="action_get_attachment_tree_view"
|
||||
type="object">
|
||||
<field name="documents_count" widget="statinfo" string="Documents"/>
|
||||
</button>
|
||||
</div>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
|
|
@ -103,6 +103,18 @@ class hr_timesheet_sheet(osv.osv):
|
|||
for sheet in self.browse(cr, uid, ids, context=context):
|
||||
if sheet.employee_id.id not in employee_ids: employee_ids.append(sheet.employee_id.id)
|
||||
return hr_employee.attendance_action_change(cr, uid, employee_ids, context=context)
|
||||
|
||||
def _count_all(self, cr, uid, ids, field_name, arg, context=None):
|
||||
res = dict(map(lambda x: (x,{'timesheet_count': 0, 'attendance_count': 0,}), ids))
|
||||
try:
|
||||
for datas in self.browse(cr, uid, ids, context=context):
|
||||
res[datas.id] = {'appraisal_count': len(datas.appraisal_ids),
|
||||
'timesheet_count': len(datas.timesheet_ids),
|
||||
'attendance_count': len(datas.attendances_ids),
|
||||
}
|
||||
except:
|
||||
pass
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Note', size=64, select=1,
|
||||
|
@ -134,6 +146,8 @@ class hr_timesheet_sheet(osv.osv):
|
|||
'account_ids': fields.one2many('hr_timesheet_sheet.sheet.account', 'sheet_id', 'Analytic accounts', readonly=True),
|
||||
'company_id': fields.many2one('res.company', 'Company'),
|
||||
'department_id':fields.many2one('hr.department','Department'),
|
||||
'timesheet_count': fields.function(_count_all, type='integer', string='Timesheet Activities', multi=True),
|
||||
'attendance_count': fields.function(_count_all, type='integer', string="Attendances", multi=True),
|
||||
}
|
||||
|
||||
def _default_date_from(self, cr, uid, context=None):
|
||||
|
|
|
@ -73,7 +73,10 @@
|
|||
<div class="oe_right oe_button_box" name="buttons">
|
||||
<button type="action"
|
||||
name="%(act_hr_timesheet_sheet_sheet_2_hr_analytic_timesheet)d"
|
||||
string="Timesheet Activities" />
|
||||
class="oe_stat_button"
|
||||
icon="fa-times">
|
||||
<field name="timesheet_count" widget="statinfo" string="Timesheet Activities"/>
|
||||
</button>
|
||||
<button type="action" groups="base.group_hr_attendance"
|
||||
name="%(act_hr_timesheet_sheet_sheet_2_hr_attendance)d"
|
||||
string="Attendances" />
|
||||
|
@ -365,7 +368,13 @@
|
|||
<field name="inherit_id" ref="hr_timesheet.hr_timesheet_employee_extd_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//div[@name='button_box']" position="inside">
|
||||
<button name="%(act_hr_employee_2_hr_timesheet)d" string="Timesheets" type="action" groups="base.group_hr_manager"/>
|
||||
<button name="%(act_hr_employee_2_hr_timesheet)d"
|
||||
type="action"
|
||||
class="oe_stat_button"
|
||||
icon="fa-clock-o"
|
||||
groups="base.group_hr_manager">
|
||||
<field name="timesheet_count" widget="statinfo" string="Timesheets"/>
|
||||
</button>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
|
Loading…
Reference in New Issue