[MERGE] improvements in payslip run

bzr revid: qdp-launchpad@openerp.com-20110609100743-ogqkahrq0pg9vz03
This commit is contained in:
Quentin (OpenERP) 2011-06-09 12:07:43 +02:00
commit 387b534a33
4 changed files with 33 additions and 11 deletions

View File

@ -211,10 +211,15 @@ class hr_payslip_run(osv.osv):
'state': fields.selection([
('draft', 'Draft'),
('close', 'Close'),
], 'State', select=True, readonly=True)
], 'State', select=True, readonly=True),
'date_start': fields.date('Date From', required=True, readonly=True, states={'draft': [('readonly', False)]}),
'date_end': fields.date('Date To', required=True, readonly=True, states={'draft': [('readonly', False)]}),
'credit_note': fields.boolean('Credit Note', readonly=True, states={'draft': [('readonly', False)]}, help="If its checked, indicates that all payslips generated from here are refund payslips."),
}
_defaults = {
'state': 'draft',
'date_start': lambda *a: time.strftime('%Y-%m-01'),
'date_end': lambda *a: str(datetime.now() + relativedelta.relativedelta(months=+1, day=1, days=-1))[:10],
}
def draft_payslip_run(self, cr, uid, ids, context=None):

View File

@ -635,6 +635,8 @@
<field name="arch" type="xml">
<search string="Search Payslips Group">
<field name="name"/>
<field name="date_start"/>
<field name="date_end"/>
</search>
</field>
</record>
@ -646,6 +648,8 @@
<field name="arch" type="xml">
<tree string="Payslips Run">
<field name="name"/>
<field name="date_start"/>
<field name="date_end"/>
</tree>
</field>
</record>
@ -656,15 +660,18 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Payslips Run">
<group col="6" colspan="6">
<field name="name"/>
<group col="6" colspan="4">
<field name="name" colspan="4"/>
<field name="credit_note"/>
<field name="date_start"/>
<field name="date_end"/>
</group>
<notebook colspan="6">
<notebook colspan="4">
<page string="Payslips">
<field name="slip_ids" colspan="4" nolabel="1"/>
</page>
</notebook>
<group col="6" colspan="6">
<group col="6" colspan="4">
<field name="state"/>
<button name="%(action_hr_payslip_by_employees)d" type="action" states="draft" icon="gtk-execute" string="Generate Payslips" />
<button name="close_payslip_run" type="object" icon="gtk-jump-to" string="Close" states="draft"/>

View File

@ -33,18 +33,25 @@ class hr_payslip_employees(osv.osv_memory):
_columns = {
'employee_ids': fields.many2many('hr.employee', 'hr_employee_group_rel', 'payslip_id', 'employee_id', 'Employees'),
}
def compute_sheet(self, cr, uid, ids, context=None):
emp_pool = self.pool.get('hr.employee')
slip_pool = self.pool.get('hr.payslip')
run_pool = self.pool.get('hr.payslip.run')
slip_ids = []
if context is None:
context = {}
data = self.read(cr, uid, ids, context=context)[0]
run_data = {}
if context and context.get('active_id', False):
run_data = run_pool.read(cr, uid, context['active_id'], ['date_start', 'date_end', 'credit_note'])
from_date = run_data.get('date_start', False)
to_date = run_data.get('date_end', False)
credit_note = run_data.get('credit_note', False)
if not data['employee_ids']:
raise osv.except_osv(_("Warning !"), _("You must select employee(s) to generate payslip(s)"))
for emp in emp_pool.browse(cr, uid, data['employee_ids'], context=context):
slip_data = slip_pool.onchange_employee_id(cr, uid, [], time.strftime('%Y-%m-01'), str(datetime.now() + relativedelta.relativedelta(months=+1, day=1, days=-1))[:10], emp.id, contract_id=False, context=context)
slip_data = slip_pool.onchange_employee_id(cr, uid, [], from_date, to_date, emp.id, contract_id=False, context=context)
res = {
'employee_id': emp.id,
'name': slip_data['value'].get('name', False),
@ -52,7 +59,10 @@ class hr_payslip_employees(osv.osv_memory):
'contract_id': slip_data['value'].get('contract_id', False),
'payslip_run_id': context.get('active_id', False),
'input_line_ids': [(0, 0, x) for x in slip_data['value'].get('input_line_ids', False)],
'worked_days_line_ids': [(0, 0, x) for x in slip_data['value'].get('worked_days_line_ids', False)]
'worked_days_line_ids': [(0, 0, x) for x in slip_data['value'].get('worked_days_line_ids', False)],
'date_from': from_date,
'date_to': to_date,
'credit_note': credit_note,
}
slip_ids.append(slip_pool.create(cr, uid, res, context=context))
slip_pool.compute_sheet(cr, uid, slip_ids, context=context)
@ -60,4 +70,4 @@ class hr_payslip_employees(osv.osv_memory):
hr_payslip_employees()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -8,9 +8,9 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Payslips by Employees">
<label colspan="4" nolabel="1" string="This wizard will generate payslips for all selected employee(s) based on the dates and credit note specified on Payslips Run." />
<group colspan="4" >
<separator string="Payslips by Employees" colspan="4"/>
<label colspan="4" nolabel="1" string="This wizard will generate payslips for all selected employee(s)" />
<separator string="Employees" colspan="4"/>
<newline/>
<field name="employee_ids" nolabel="1"/>
</group>