[IMP/ADD]l10n_in_hr_payroll:added category field on wizard and improved code of report by using this field

bzr revid: kbh@tinyerp.com-20120809072235-a7a1cifqsveuu33k
This commit is contained in:
Khushboo Bhatt (Open ERP) 2012-08-09 12:52:35 +05:30
parent 4546c6fe3c
commit 3cef19e555
3 changed files with 12 additions and 11 deletions

View File

@ -68,20 +68,18 @@ class report_hr_salary_employee_bymonth(report_sxw.rml_parse):
self.mnths.append('None')
return [mnth_name]
def get_salary(self, form, emp_id, emp_salary, total_mnths):
emp_obj = self.pool.get('hr.employee')
date_from = form.get('start_date', [])
date_to = form.get('end_date', [])
emp_ids = form.get('employee_ids', [])
employees = emp_obj.browse(self.cr, self.uid, emp_ids, context=self.context)
def get_salary(self, form, emp_id, emp_salary, total_mnths, category):
ids = []
category_ids = form.get('category_id', [])
ids.append(category_ids[0])
self.cr.execute("select to_char(date_to,'mm-yyyy') as to_date ,sum(pl.total) as net \
self.cr.execute("select to_char(date_to,'mm-yyyy') as to_date ,sum(pl.total) \
from hr_payslip_line as pl \
left join hr_payslip as p on pl.slip_id = p.id \
left join hr_employee as emp on emp.id = p.employee_id \
left join resource_resource as r on r.id = emp.resource_id \
where pl.code = 'NET' and p.state = 'done' and p.employee_id = %s \
group by r.name, p.date_to,emp.id",(emp_id,))
where p.state = 'done' and p.employee_id = %s and pl.category_id in %s \
group by r.name, p.date_to,emp.id",(emp_id,tuple(ids),))
sal = self.cr.fetchall()
salary = dict(sal)
total = 0.0
@ -107,6 +105,7 @@ class report_hr_salary_employee_bymonth(report_sxw.rml_parse):
emp_salary = []
salary_list = []
total_mnths=['Total', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
category = form.get('category_id', [])
emp_obj = self.pool.get('hr.employee')
emp_ids = form.get('employee_ids', [])
employees = emp_obj.browse(self.cr, self.uid, emp_ids, context=self.context)
@ -114,7 +113,7 @@ class report_hr_salary_employee_bymonth(report_sxw.rml_parse):
for emp_id in employees:
emp_salary.append(emp_id.name)
total = 0.0
emp_salary, total, total_mnths = self.get_salary(form, emp_id.id, emp_salary, total_mnths)
emp_salary, total, total_mnths = self.get_salary(form, emp_id.id, emp_salary, total_mnths, category)
emp_salary.append(total)
salary_list.append(emp_salary)
emp_salary = []

View File

@ -31,6 +31,7 @@ class hr_salary_employee_bymonth(osv.osv_memory):
'start_date': fields.date('Start Date', required=True),
'end_date': fields.date('End Date', required=True),
'employee_ids': fields.many2many('hr.employee', 'payroll_year_rel', 'payroll_year_id', 'employee_id', 'Employees', required=True),
'category_id': fields.many2one('hr.salary.rule.category', 'Category', required=True),
}
_defaults = {
@ -51,7 +52,7 @@ class hr_salary_employee_bymonth(osv.osv_memory):
context = {}
datas = {'ids': context.get('active_ids', [])}
res = self.read(cr, uid, ids, ['employee_ids', 'start_date', 'end_date'], context=context)
res = self.read(cr, uid, ids, ['category_id', 'employee_ids', 'start_date', 'end_date'], context=context)
res = res and res[0] or {}
datas.update({'form': res})
return {

View File

@ -16,6 +16,7 @@
<group>
<field name="start_date"/>
<field name="end_date"/>
<field name="category_id"/>
<separator string="Employees" />
<field name="employee_ids" nolabel="1" colspan="4"/>
</group>