[IMP]hr_payroll: create button
bzr revid: pat@tinyerp.com-20120713104501-kp20pumuiyrwdaip
This commit is contained in:
@@ -236,7 +236,35 @@ class hr_payslip_run(osv.osv):
|
||||
def close_payslip_run(self, cr, uid, ids, context=None):
|
||||
return self.write(cr, uid, ids, {'state': 'close'}, context=context)
|
||||
|
||||
hr_payslip_run()
|
||||
def create_advice_run(self, cr, uid, ids, context=None):
|
||||
advice_pool = self.pool.get('hr.payroll.advice')
|
||||
advice_line_pool = self.pool.get('hr.payroll.advice.line')
|
||||
payslip_pool = self.pool.get('hr.payslip')
|
||||
payslip_line_pool = self.pool.get('hr.payslip.line')
|
||||
users = self.pool.get('res.users').browse(cr, uid, [uid], context=context)
|
||||
for run in self.browse(cr, uid, ids, context=context):
|
||||
advice_data = {
|
||||
'company_id': users[0].company_id.id,
|
||||
'name': run.name,
|
||||
'date': run.date_end,
|
||||
'bank_id': users[0].company_id.bank_ids and users[0].company_id.bank_ids[0].id or False
|
||||
}
|
||||
advice_id = advice_pool.create(cr, uid, advice_data, context=context)
|
||||
slip_ids = payslip_pool.search(cr, uid, [('payslip_run_id', '=', run.id), ('state', '=', 'done')], context=context)
|
||||
for slip in payslip_pool.browse(cr, uid, slip_ids, context=context):
|
||||
if not slip.employee_id.bank_account_id and not slip.employee_id.bank_account_id.acc_number:
|
||||
raise osv.except_osv(_('Error !'), _('Please define bank account for the %s employee') % (slip.employee_id.name))
|
||||
line_ids = payslip_line_pool.search(cr, uid, [('slip_id', '=', slip.id), ('code', '=', 'NET')], context=context)
|
||||
if line_ids:
|
||||
line = payslip_line_pool.browse(cr, uid, line_ids, context=context)[0]
|
||||
advice_line = {
|
||||
'advice_id': advice_id,
|
||||
'name': slip.employee_id.bank_account_id.acc_number,
|
||||
'employee_id': slip.employee_id.id,
|
||||
'bysal': line.total
|
||||
}
|
||||
advice_line_id = advice_line_pool.create(cr, uid, advice_line, context=context)
|
||||
return True
|
||||
|
||||
class hr_payslip(osv.osv):
|
||||
'''
|
||||
@@ -278,7 +306,7 @@ class hr_payslip(osv.osv):
|
||||
\n* If the payslip is confirmed then state is set to \'Done\'.\
|
||||
\n* When user cancel payslip the state is \'Rejected\'.'),
|
||||
# 'line_ids': fields.one2many('hr.payslip.line', 'slip_id', 'Payslip Line', required=False, readonly=True, states={'draft': [('readonly', False)]}),
|
||||
'line_ids': fields.one2many('hr.payslip.line', 'slip_id', 'Payslip Lines', readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'line_ids': one2many_mod2('hr.payslip.line', 'slip_id', 'Payslip Lines', readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'company_id': fields.many2one('res.company', 'Company', required=False, readonly=True, states={'draft': [('readonly', False)]}),
|
||||
'worked_days_line_ids': fields.one2many('hr.payslip.worked_days', 'payslip_id', 'Payslip Worked Days', required=False, readonly=True, states={'draft': [('readonly', False)]}),
|
||||
'input_line_ids': fields.one2many('hr.payslip.input', 'payslip_id', 'Payslip Inputs', required=False, readonly=True, states={'draft': [('readonly', False)]}),
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<page string="Miscellaneous" groups="base.group_hr_user">
|
||||
<group colspan="2" col="2">
|
||||
<separator string="Personal Info" colspan="2"/>
|
||||
<field name="bank_account_id" context="{'display_partner':True, 'partner_id':partner_id}"/>
|
||||
<field name="bank_account_id"/>
|
||||
<field name="place_of_birth"/>
|
||||
<field name="children"/>
|
||||
<!-- <field name="basic" invisible="0"/> -->
|
||||
@@ -727,6 +727,7 @@
|
||||
<button name="close_payslip_run" type="object" string="Close" states="draft" class="oe_highlight"/>
|
||||
<button name="%(action_hr_payslip_by_employees)d" type="action" states="draft" string="Generate Payslips" class="oe_highlight"/>
|
||||
<button name="draft_payslip_run" string="Set to Draft" type="object" states="close" />
|
||||
<button name="create_advice_run" string="Create Advice" type="object" states="close" />
|
||||
<field name="state" widget="statusbar"/>
|
||||
</header>
|
||||
<sheet>
|
||||
|
||||
@@ -131,7 +131,6 @@ class payroll_advice(osv.osv):
|
||||
self.pool.get('res.users').browse(cr, uid, uid,
|
||||
context=context).company_id.id,
|
||||
'note': "Please make the payroll transfer from above account number to the below mentioned account numbers towards employee salaries:"
|
||||
|
||||
}
|
||||
|
||||
def compute_advice(self, cr, uid, ids, context=None):
|
||||
@@ -211,45 +210,6 @@ class payroll_advice(osv.osv):
|
||||
|
||||
payroll_advice()
|
||||
|
||||
class hr_payslip_run(osv.osv):
|
||||
|
||||
_inherit = 'hr.payslip.run'
|
||||
_description = 'Payslip Batches'
|
||||
_columns = {
|
||||
}
|
||||
|
||||
def close_payslip_run(self, cr, uid, ids, context=None):
|
||||
|
||||
payslip_pool = self.pool.get('hr.payslip')
|
||||
payslip_run_pool = self.pool.get('hr.payslip.run')
|
||||
advice_line_pool = self.pool.get('hr.payroll.advice.line')
|
||||
advice_pool = self.pool.get('hr.payroll.advice')
|
||||
payslip_line_pool = self.pool.get('hr.payslip.line')
|
||||
|
||||
for advice in self.browse(cr, uid, ids, context=context):
|
||||
for slip in advice.slip_ids:
|
||||
if slip.id:
|
||||
line = payslip_line_pool.browse(cr, uid, ids, context=context)[0]
|
||||
advice_line = advice_pool.browse(cr, uid, ids, context=context)[0]
|
||||
adv = {
|
||||
'advice_id': advice.id,
|
||||
'name': slip.employee_id.name,
|
||||
'employee_id': slip.employee_id.id,
|
||||
}
|
||||
advice_record = advice_pool.create(cr, uid, adv, context=context)
|
||||
advice_line = {
|
||||
'advice_id': advice.id,
|
||||
'name': slip.employee_id.name,
|
||||
'employee_id': slip.employee_id.id,
|
||||
}
|
||||
adviceline_record = advice_line_pool.create(cr, uid, advice_line, context=context)
|
||||
payslip_record = payslip_pool.write(cr, uid, ids, {'advice_id': advice.id, 'name': slip.employee_id.name, 'employee_id': slip.employee_id.id}, context=context)
|
||||
return super(hr_payslip_run, self).close_payslip_run(cr, uid, ids, context=context)
|
||||
|
||||
return True
|
||||
|
||||
hr_payslip_run()
|
||||
|
||||
class payroll_advice_line(osv.osv):
|
||||
'''
|
||||
Bank Advice Lines
|
||||
|
||||
Reference in New Issue
Block a user