From 3cef19e55561b8c8c7e4d80792cb28f866f50c6b Mon Sep 17 00:00:00 2001 From: "Khushboo Bhatt (Open ERP)" Date: Thu, 9 Aug 2012 12:52:35 +0530 Subject: [PATCH] [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 --- .../report_hr_salary_employee_bymonth.py | 19 +++++++++---------- .../wizard/hr_salary_employee_bymonth.py | 3 ++- .../hr_salary_employee_bymonth_view.xml | 1 + 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/addons/l10n_in_hr_payroll/report/report_hr_salary_employee_bymonth.py b/addons/l10n_in_hr_payroll/report/report_hr_salary_employee_bymonth.py index f2c693ef6d1..cf66edccbf5 100644 --- a/addons/l10n_in_hr_payroll/report/report_hr_salary_employee_bymonth.py +++ b/addons/l10n_in_hr_payroll/report/report_hr_salary_employee_bymonth.py @@ -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 = [] diff --git a/addons/l10n_in_hr_payroll/wizard/hr_salary_employee_bymonth.py b/addons/l10n_in_hr_payroll/wizard/hr_salary_employee_bymonth.py index f8be2799f35..e939273d40a 100644 --- a/addons/l10n_in_hr_payroll/wizard/hr_salary_employee_bymonth.py +++ b/addons/l10n_in_hr_payroll/wizard/hr_salary_employee_bymonth.py @@ -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 { diff --git a/addons/l10n_in_hr_payroll/wizard/hr_salary_employee_bymonth_view.xml b/addons/l10n_in_hr_payroll/wizard/hr_salary_employee_bymonth_view.xml index 10088dd2265..e05519b08db 100644 --- a/addons/l10n_in_hr_payroll/wizard/hr_salary_employee_bymonth_view.xml +++ b/addons/l10n_in_hr_payroll/wizard/hr_salary_employee_bymonth_view.xml @@ -16,6 +16,7 @@ +