[IMP]L improvement and fix to the payroll module

bzr revid: mga@tinyerp.com-20101007063156-tijiyci4w5r0v29w
This commit is contained in:
Mantavya Gajjar 2010-10-07 12:01:56 +05:30
parent d2611e0765
commit 52462287f3
4 changed files with 65 additions and 19 deletions

View File

@ -492,8 +492,13 @@ class payment_category(osv.osv):
'type':fields.selection([
('allowance','Allowance'),
('deduction','Deduction'),
('other','Others'),
],'Type', select=True),
('leaves','Leaves'),
('advance','Advance'),
('loan','Loan'),
('installment','Loan Installment'),
('otherpay','Other Payment'),
('otherdeduct','Other Deduction'),
],'Type', select=True, required=True),
'base':fields.text('Based on', required=True, readonly=False, help='This will use to computer the % fields values, in general its on basic, but You can use all heads code field in small letter as a variable name i.e. hra, ma, lta, etc...., also you can use, static varible basic'),
'condition':fields.char('Condition', size=1024, required=True, readonly=False, help='Applied this head for calculation if condition is true'),
'sequence': fields.integer('Sequence', required=True, help='Use to arrange calculation sequence'),
@ -620,7 +625,8 @@ class hr_holidays_status(osv.osv):
('halfpaid','Half-Pay Holiday')
], string='Payment'),
'head_id': fields.many2one('hr.allounce.deduction.categoty', 'Payroll Head', domain=[('type','=','deduction')]),
'code':fields.char('Code', size=64, required=False, readonly=False),
'code': fields.related('head_id','code', type='char', relation='hr.allounce.deduction.categoty', string='Code'),
# 'code':fields.char('Code', size=64, required=False, readonly=False),
}
_defaults = {
'type': lambda *args: 'unpaid',
@ -1057,6 +1063,9 @@ class hr_payslip(osv.osv):
total_leave = 0.0
paid_leave = 0.0
for hday in holiday_pool.browse(cr, uid, leave_ids, context=context):
if not hday.holiday_status_id.head_id:
raise osv.except_osv(_('Error !'), _('Please check configuration of %s, payroll head is missing' % (hday.holiday_status_id.name)))
res = {
'slip_id':slip.id,
'name':hday.holiday_status_id.name + '-%s' % (hday.number_of_days),
@ -1141,7 +1150,8 @@ class hr_payslip_line(osv.osv):
'employee_id':fields.many2one('hr.employee', 'Employee', required=False),
'name':fields.char('Name', size=256, required=True, readonly=False),
'base':fields.char('Formula', size=1024, required=False, readonly=False),
'code':fields.char('Code', size=64, required=False, readonly=False),
'code':fields.char('Code', size=64, required=False, readonly=False),
'category_id':fields.many2one('hr.allounce.deduction.categoty', 'Category', required=True),
'type':fields.selection([
('allowance','Allowance'),
('deduction','Deduction'),
@ -1152,12 +1162,13 @@ class hr_payslip_line(osv.osv):
('otherpay','Other Payment'),
('otherdeduct','Other Deduction'),
],'Type', select=True, required=True),
'category_id':fields.many2one('hr.allounce.deduction.categoty', 'Category', required=True),
#TODO: link type to the category_id instead of define again
#'type': fields.related('category_id','type', type='selection', size=64, relation='hr.allounce.deduction.categoty', string='Type', store=True),
'amount_type':fields.selection([
('per','Percentage (%)'),
('fix','Fixed Amount'),
('func','Function Value'),
],'Amount Type', select=True),
],'Amount Type', select=True, required=True),
'amount': fields.float('Amount / Percentage', digits=(16, 4)),
'total': fields.float('Sub Total', readonly=True, digits=(16, 4)),
'company_contrib': fields.float('Company Contribution', readonly=True, digits=(16, 4)),
@ -1166,6 +1177,9 @@ class hr_payslip_line(osv.osv):
'line_ids':fields.one2many('hr.payslip.line.line', 'slipline_id', 'Calculations', required=False)
}
_order = 'sequence'
_defaults = {
'amount_type': lambda *a: 'per'
}
def execute_function(self, cr, uid, id, value, context=None):
if context is None:

View File

@ -115,14 +115,14 @@
<record id="OTHERD" model="hr.allounce.deduction.categoty">
<field name="code">OTHERD</field>
<field name="type">deduction</field>
<field name="type">otherdeduct</field>
<field name="name">Other Deduction</field>
<field name="sequence" eval="85"/>
</record>
<record id="OTHERA" model="hr.allounce.deduction.categoty">
<field name="code">OTHERA</field>
<field name="type">allowance</field>
<field name="type">otherpay</field>
<field name="name">Other Taxable Allowance</field>
<field name="sequence" eval="90"/>
</record>

View File

@ -16,7 +16,6 @@
<field eval="0.4" name="amount"/>
<field name="code">HRA</field>
<field name="category_id" ref="hr_payroll.HRA"/>
<field name="type">allowance</field>
<field name="function_id" ref="hr_payroll.structure_001"/>
<field name="name">House Rant Allowance</field>
</record>
@ -28,7 +27,6 @@
<field eval="800.0" name="amount"/>
<field name="code">CA</field>
<field name="category_id" ref="hr_payroll.CA"/>
<field name="type">allowance</field>
<field name="function_id" ref="hr_payroll.structure_001"/>
<field name="name">Convance Allowance</field>
</record>
@ -40,7 +38,6 @@
<field eval="200.0" name="amount"/>
<field name="code">PT</field>
<field name="category_id" ref="hr_payroll.PT"/>
<field name="type">deduction</field>
<field name="function_id" ref="hr_payroll.structure_001"/>
<field name="name">Professional Tax</field>
</record>
@ -52,7 +49,6 @@
<field eval="0.125" name="amount"/>
<field name="code">PF</field>
<field name="category_id" ref="hr_payroll.PF"/>
<field name="type">deduction</field>
<field name="function_id" ref="hr_payroll.structure_001"/>
<field name="name">Provident Fund</field>
</record>

View File

@ -350,16 +350,17 @@
<field name="inherit_id" ref="hr_holidays.edit_holiday_status_form"/>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="color_name" position="after">
<group col="2" colspan="2">
<separator colspan="4" string="Payroll Accounting"/>
<field name="company_id" groups="base.group_multi_company" widget="selection" select="2"/>
<field name="code"/>
</group>
<field name="double_validation" position="replace">
<group col="2" colspan="2">
<separator colspan="4" string="Payroll Configurtion"/>
<field name="type"/>
<field name="head_id"/>
<field name="company_id" groups="base.group_multi_company" widget="selection" select="2"/>
<field name="code" readonly="True"/>
</group>
<group col="2" colspan="2">
<separator colspan="4" string="Validation"/>
<field name="double_validation"/>
</group>
</field>
</field>
@ -586,7 +587,42 @@
<field name="note" colspan="4" nolabel="1"/>
</page>
<page string="Contribution">
<field name="contribute_ids" colspan="4" nolabel="1" height="300"/>
<field name="contribute_ids" colspan="4" nolabel="1" height="300">
<form string="Company Contribution">
<group col="6" colspan="6">
<field name="name" select="1"/>
<field name="code" select="1"/>
</group>
<group col="2" colspan="2">
<separator colspan="2" string="Contributions"/>
<field name="amount_type" attrs="{'required': [('contribute','=',True)]}"/>
<field name="contribute_per" attrs="{'required': [('contribute','=',True)], 'readonly':[(('amount_type','=','func'))]}"/>
<field name="register_id" attrs="{'required': [('contribute','=',True)]}"/>
</group>
<group col="2" colspan="2">
<separator colspan="2" string="Other Information"/>
<field name="company_id" groups="base.group_multi_company" widget="selection" select="1"/>
<field name="active" select="1"/>
</group>
<notebook colspan="4">
<page string="Function" attrs="{'readonly': [('amount_type','!=','func')]}">
<field name="line_ids" colspan="4" nolabel="1">
<tree string="Function Arguments" editable="bottom">
<field name="name"/>
<field name="sequence"/>
<field name="from_val"/>
<field name="to_val"/>
<field name="amount_type"/>
<field name="value"/>
</tree>
</field>
</page>
<page string="Description">
<field name="note" colspan="4" nolabel="1"/>
</page>
</notebook>
</form>
</field>
</page>
</notebook>
</form>