[IMP] hr_payroll: added fields and assigned value to start_date and end_date on payslip run
bzr revid: mtr@mtr-20110518050148-hhomxkvrsjot786n
This commit is contained in:
parent
7499c98d42
commit
c22f7fece7
|
@ -211,7 +211,10 @@ 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=False),
|
||||
'date_end': fields.date('Date To', required=False),
|
||||
'credit_note': fields.boolean('Credit Note', help="Indicates this payslip has a refund of another"),
|
||||
}
|
||||
_defaults = {
|
||||
'state': 'draft',
|
||||
|
|
|
@ -649,8 +649,11 @@
|
|||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Payslips Run">
|
||||
<group col="6" colspan="6">
|
||||
<group col="4" colspan="2">
|
||||
<field name="name"/>
|
||||
<field name="credit_note"/>
|
||||
<field name="date_start"/>
|
||||
<field name="date_end"/>
|
||||
</group>
|
||||
<notebook colspan="6">
|
||||
<page string="Payslips">
|
||||
|
|
|
@ -37,14 +37,17 @@ class hr_payslip_employees(osv.osv_memory):
|
|||
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 = []
|
||||
from_date = time.strftime('%Y-%m-01')
|
||||
to_date = str(datetime.now() + relativedelta.relativedelta(months=+1, day=1, days=-1))[:10]
|
||||
if context is None:
|
||||
context = {}
|
||||
data = self.read(cr, uid, ids, context=context)[0]
|
||||
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),
|
||||
|
@ -55,6 +58,7 @@ class hr_payslip_employees(osv.osv_memory):
|
|||
'worked_days_line_ids': [(0, 0, x) for x in slip_data['value'].get('worked_days_line_ids', False)]
|
||||
}
|
||||
slip_ids.append(slip_pool.create(cr, uid, res, context=context))
|
||||
run_pool.write(cr, uid, context.get('active_ids', []), {'date_start': from_date, 'date_end': to_date})
|
||||
slip_pool.compute_sheet(cr, uid, slip_ids, context=context)
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
|
||||
|
|
Loading…
Reference in New Issue