[IMP] hr_payroll: Holidays for multiple contracts
bzr revid: psi@tinyerp.co.in-20110329072648-e9dilqyvijhv6li2
This commit is contained in:
@@ -182,36 +182,31 @@ class payroll_register(osv.osv):
|
||||
def compute_sheet(self, cr, uid, ids, context=None):
|
||||
emp_pool = self.pool.get('hr.employee')
|
||||
slip_pool = self.pool.get('hr.payslip')
|
||||
slip_line_pool = self.pool.get('hr.payslip.line')
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
|
||||
if context is None:
|
||||
context = {}
|
||||
vals = self.browse(cr, uid, ids[0], context=context)
|
||||
|
||||
emp_ids = emp_pool.search(cr, uid, [], context=context)
|
||||
|
||||
for emp in emp_pool.browse(cr, uid, emp_ids, context=context):
|
||||
old_slips = slip_pool.search(cr, uid, [('employee_id','=', emp.id), ('date','=',vals.date)], context=context)
|
||||
if old_slips:
|
||||
slip_pool.write(cr, uid, old_slips, {'register_id':ids[0]}, context=context)
|
||||
for sid in old_slips:
|
||||
wf_service.trg_validate(uid, 'hr.payslip', sid, 'compute_sheet', cr)
|
||||
else:
|
||||
res = {
|
||||
'employee_id': emp.id,
|
||||
'basic_amount': 0.0,
|
||||
# 'basic_amount': 0.0,
|
||||
'register_id': ids[0],
|
||||
'name': vals.name,
|
||||
'date': vals.date,
|
||||
}
|
||||
slip_id = slip_pool.create(cr, uid, res, context=context)
|
||||
data = slip_pool.onchange_employee_id(cr, uid, [slip_id], vals.date, emp.id, contract_id=False, context=context) # fix me can we pass contract_id ?
|
||||
for line in data['value']['line_ids']:
|
||||
line.update({'slip_id': slip_id})
|
||||
slip_line_pool.create(cr, uid, line, context=context)
|
||||
data['value'].pop('line_ids')
|
||||
slip_pool.write(cr, uid, [slip_id], data['value'], context=context)
|
||||
wf_service.trg_validate(uid, 'hr.payslip', slip_id, 'compute_sheet', cr)
|
||||
|
||||
number = self.pool.get('ir.sequence').get(cr, uid, 'salary.register')
|
||||
return self.write(cr, uid, ids, {'state': 'draft', 'number': number}, context=context)
|
||||
self.write(cr, uid, ids, {'state': 'draft', 'number': number}, context=context)
|
||||
return True
|
||||
|
||||
# def compute_sheet(self, cr, uid, ids, context=None):
|
||||
# emp_pool = self.pool.get('hr.employee')
|
||||
@@ -590,8 +585,8 @@ class hr_payslip(osv.osv):
|
||||
'move_payment_ids': False,
|
||||
'company_id': company_id,
|
||||
'period_id': False,
|
||||
'basic_before_leaves': 0,
|
||||
'basic_amount': 0
|
||||
'basic_before_leaves': 0.0,
|
||||
'basic_amount': 0.0
|
||||
}
|
||||
return super(hr_payslip, self).copy(cr, uid, id, default, context=context)
|
||||
#
|
||||
@@ -720,7 +715,7 @@ class hr_payslip(osv.osv):
|
||||
else:
|
||||
contracts = [contract_obj.read(cr, uid, contract_id, ['wage', 'struct_id', 'id'], context=context)]
|
||||
update.update({
|
||||
'struct_id': contracts[0].get('struct_id', False),
|
||||
'struct_id': contracts[0].get('struct_id', False)[0],
|
||||
'contract_id': contract_id
|
||||
})
|
||||
if not contracts:
|
||||
@@ -735,12 +730,11 @@ class hr_payslip(osv.osv):
|
||||
})
|
||||
self.write(cr, uid, [slip.id], update, context=context)
|
||||
continue
|
||||
|
||||
for contract in contracts:
|
||||
if contract.get('id', False) == False:
|
||||
continue
|
||||
contract_id = contract.get('id')
|
||||
contract = self.pool.get('hr.contract').browse(cr, uid, contract_id, context=context)
|
||||
contract = contract_obj.browse(cr, uid, contract_id, context=context)
|
||||
function = contract.struct_id.id
|
||||
sal_structure = []
|
||||
if function:
|
||||
@@ -813,7 +807,7 @@ class hr_payslip(osv.osv):
|
||||
else:
|
||||
value = line.amount
|
||||
elif line.amount_type=='code':
|
||||
localdict = {'basic':amt, 'employee':slip.employee_id, 'contract':contract}
|
||||
localdict = {'basic': amt, 'employee': slip.employee_id, 'contract': contract}
|
||||
exec line.python_compute in localdict
|
||||
value = localdict['result']
|
||||
total += value
|
||||
@@ -841,24 +835,19 @@ class hr_payslip(osv.osv):
|
||||
else:
|
||||
slip_line_pool.create(cr, uid, vals, {})
|
||||
|
||||
basic = contract.wage
|
||||
number = sequence_obj.get(cr, uid, 'salary.slip')
|
||||
update.update({
|
||||
'struct_id': function,
|
||||
'number': number,
|
||||
'basic_amount': basic,
|
||||
'basic_before_leaves': basic,
|
||||
'total_pay': basic + total,
|
||||
'name': 'Salary Slip of %s for %s' % (slip.employee_id.name, tools.ustr(ttyme.strftime('%B-%Y'))),
|
||||
'state':'draft',
|
||||
'contract_id': contract.id,
|
||||
'company_id': slip.employee_id.company_id.id
|
||||
})
|
||||
self.write(cr, uid, [slip.id], update, context=context)
|
||||
basic = contract.wage
|
||||
number = sequence_obj.get(cr, uid, 'salary.slip')
|
||||
update.update({
|
||||
'number': number,
|
||||
'basic_amount': basic,
|
||||
'basic_before_leaves': basic,
|
||||
'total_pay': basic + total,
|
||||
'name': 'Salary Slip of %s for %s' % (slip.employee_id.name, tools.ustr(ttyme.strftime('%B-%Y'))),
|
||||
'state':'draft',
|
||||
'company_id': slip.employee_id.company_id.id
|
||||
})
|
||||
self.write(cr, uid, [slip.id], update, context=context)
|
||||
|
||||
for slip in self.browse(cr, uid, ids, context=context):
|
||||
if not slip.contract_id:
|
||||
continue
|
||||
basic_before_leaves = slip.basic_amount
|
||||
working_day = 0
|
||||
off_days = 0
|
||||
@@ -893,7 +882,7 @@ class hr_payslip(osv.osv):
|
||||
raise osv.except_osv(_('Error !'), _('Please check configuration of %s, Salary rule is missing') % (hday.holiday_status_id.name))
|
||||
salary_rule = salary_rule_pool.browse(cr, uid, slip_lines, context=context)[0]
|
||||
base = salary_rule.computational_expression
|
||||
|
||||
obj = {'basic': hday.contract_id.wage}
|
||||
res = {
|
||||
'slip_id': slip.id,
|
||||
'name': salary_rule.name + '-%s' % (hday.number_of_days),
|
||||
@@ -962,6 +951,7 @@ class hr_payslip(osv.osv):
|
||||
|
||||
update = {'value':{'line_ids':[], 'holiday_ids':[], 'name':'', 'working_days': 0.0, 'holiday_days': 0.0, 'worked_days': 0.0, 'basic_before_leaves': 0.0, 'basic_amount': 0.0, 'leaves': 0.0, 'total_pay': 0.0}}
|
||||
if not employee_id:
|
||||
update['value'].update({'contract_id': False, 'struct_id': False})
|
||||
return update
|
||||
|
||||
employee_id = empolyee_obj.browse(cr, uid, employee_id, context=context)
|
||||
@@ -982,7 +972,7 @@ class hr_payslip(osv.osv):
|
||||
'name':'Salary Slip of %s for %s' % (employee_id.name, tools.ustr(ttyme.strftime('%B-%Y'))),
|
||||
'contract_id': False,
|
||||
'struct_id': False,
|
||||
'company_id':employee_id.company_id.id
|
||||
'company_id': employee_id.company_id.id
|
||||
})
|
||||
return update
|
||||
final_total = 0.0
|
||||
@@ -991,7 +981,7 @@ class hr_payslip(osv.osv):
|
||||
if contract.get('id', False) == False:
|
||||
continue
|
||||
contract_id = contract.get('id')
|
||||
contract_id = self.pool.get('hr.contract').browse(cr, uid, contract_id, context=context)
|
||||
contract_id = contract_obj.browse(cr, uid, contract_id, context=context)
|
||||
function = contract_id.struct_id.id
|
||||
sal_structure = []
|
||||
if function:
|
||||
@@ -1156,7 +1146,7 @@ class hr_payslip(osv.osv):
|
||||
leave_rule.append(hd_rule)
|
||||
if hd_rule.child_ids:
|
||||
leave_rule.append((hd_rule.child_ids[0]))
|
||||
|
||||
obj = {'basic': hday.contract_id.wage}
|
||||
for salary_rule in leave_rule:
|
||||
base = salary_rule.computational_expression
|
||||
res = {
|
||||
@@ -1266,7 +1256,8 @@ class hr_holidays(osv.osv):
|
||||
|
||||
_inherit = "hr.holidays"
|
||||
_columns = {
|
||||
'payslip_id':fields.many2one('hr.payslip', 'Payslip'),
|
||||
'payslip_id': fields.many2one('hr.payslip', 'Payslip'),
|
||||
'contract_id': fields.many2one('hr.contract', 'Contract', readonly=True, states={'draft':[('readonly',False)]})
|
||||
}
|
||||
|
||||
hr_holidays()
|
||||
@@ -1305,7 +1296,7 @@ class hr_payslip_line(osv.osv):
|
||||
'base':fields.char('Formula', size=1024, required=False, readonly=False),
|
||||
'code':fields.char('Code', size=64, required=False, readonly=False),
|
||||
'category_id':fields.many2one('hr.salary.head', 'Salary Head', required=True),
|
||||
'type':fields.related('category_id','type', relation='hr.salary.head.type', string='Salary Head Type', type='many2one', store=True), #many2one('hr.salary.head.type', 'Type', required=True, help="Used for the reporting purpose."),
|
||||
'type':fields.related('category_id', 'type', relation='hr.salary.head.type', string='Salary Head Type', type='many2one', store=True), #many2one('hr.salary.head.type', 'Type', required=True, help="Used for the reporting purpose."),
|
||||
'amount_type':fields.selection([
|
||||
('per','Percentage (%)'),
|
||||
('fix','Fixed Amount'),
|
||||
|
||||
@@ -56,6 +56,23 @@
|
||||
|
||||
<!-- End Contract View-->
|
||||
|
||||
<!-- Holidays View -->
|
||||
<record id="hr_holidays_form_inherit" model="ir.ui.view">
|
||||
<field name="name">hr.holidays.view.form.inherit</field>
|
||||
<field name="model">hr.holidays</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="hr_holidays.edit_holiday_new"/>
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<xpath expr="/form/notebook/page/field[@name='number_of_days_temp']" position="after">
|
||||
<field name="contract_id" select="1" domain="[('employee_id', '=', employee_id)]" attrs="{'invisible':[('holiday_type','=','category')], 'required':[('holiday_type','=','employee')]}"/>
|
||||
</xpath>
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- End Holidays View-->
|
||||
|
||||
<!-- Salary structure -->
|
||||
<record id="view_hr_employee_grade_tree" model="ir.ui.view">
|
||||
<field name="name">hr.payroll.structure.tree</field>
|
||||
@@ -253,9 +270,9 @@
|
||||
</notebook>
|
||||
</form>
|
||||
</field>
|
||||
<group col="6" colspan="4">
|
||||
<!-- <group col="6" colspan="4">
|
||||
<separator string="Computation Overview" colspan="6"/>
|
||||
<!--<field name="working_days"/>
|
||||
<field name="working_days"/>
|
||||
<field name="holiday_days"/>
|
||||
<field name="worked_days"/>
|
||||
<field name="basic_before_leaves"/>
|
||||
@@ -264,9 +281,9 @@
|
||||
<field name="allounce"/>
|
||||
<field name="deduction"/>
|
||||
<field name="grows"/>
|
||||
<field name="net"/>-->
|
||||
<field name="net"/>
|
||||
<field name="total_pay"/>
|
||||
</group>
|
||||
</group> -->
|
||||
</page>
|
||||
<page string="Holidays">
|
||||
<field name="holiday_ids" colspan="4" nolabel="1" editable="bottom"/>
|
||||
|
||||
Reference in New Issue
Block a user