[MERGE] hr_payroll: Merge with main payroll branch
bzr revid: psi@tinyerp.co.in-20110526053146-cybrig63j99qt4tx
This commit is contained in:
commit
4f1ed7c970
|
@ -255,19 +255,15 @@ class hr_payslip(osv.osv):
|
|||
'date_from': fields.date('Date From', readonly=True, states={'draft': [('readonly', False)]}, required=True),
|
||||
'date_to': fields.date('Date To', readonly=True, states={'draft': [('readonly', False)]}, required=True),
|
||||
'state': fields.selection([
|
||||
('draft', 'Waiting for Verification'),
|
||||
('hr_check', 'Waiting for HR Verification'),
|
||||
('accont_check', 'Waiting for Account Verification'),
|
||||
('confirm', 'Confirm Sheet'),
|
||||
('done', 'Paid Salary'),
|
||||
('cancel', 'Reject'),
|
||||
('draft', 'Draft'),
|
||||
('verify', 'Waiting'),
|
||||
('done', 'Done'),
|
||||
('cancel', 'Rejected'),
|
||||
], 'State', select=True, readonly=True,
|
||||
help=' * When the payslip is created the state is \'Waiting for verification\'.\
|
||||
\n* It is varified by the user and payslip is sent for HR varification, the state is \'Waiting for HR Verification\'. \
|
||||
\n* If HR varify the payslip, it is sent for account verification, the state is \'Waiting for Account Verification\'. \
|
||||
\n* It is confirmed by the accountant and the state set to \'Confirm Sheet\'.\
|
||||
\n* If the salary is paid then state is set to \'Paid Salary\'.\
|
||||
\n* The \'Reject\' state is used when user cancel payslip.'),
|
||||
help='* When the payslip is created the state is \'Draft\'.\
|
||||
\n* If the payslip is under verification, the state is \'Waiting\'. \
|
||||
\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': 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)]}),
|
||||
|
@ -308,23 +304,19 @@ class hr_payslip(osv.osv):
|
|||
def cancel_sheet(self, cr, uid, ids, context=None):
|
||||
return self.write(cr, uid, ids, {'state': 'cancel'}, context=context)
|
||||
|
||||
def account_check_sheet(self, cr, uid, ids, context=None):
|
||||
return self.write(cr, uid, ids, {'state': 'accont_check'}, context=context)
|
||||
|
||||
def hr_check_sheet(self, cr, uid, ids, context=None):
|
||||
return self.write(cr, uid, ids, {'state': 'hr_check'}, context=context)
|
||||
|
||||
def process_sheet(self, cr, uid, ids, context=None):
|
||||
return self.write(cr, uid, ids, {'paid': True, 'state': 'done'}, context=context)
|
||||
|
||||
def hr_verify_sheet(self, cr, uid, ids, context=None):
|
||||
return self.write(cr, uid, ids, {'state': 'verify'}, context=context)
|
||||
|
||||
def refund_sheet(self, cr, uid, ids, context=None):
|
||||
mod_obj = self.pool.get('ir.model.data')
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
for id in ids:
|
||||
id_copy = self.copy(cr, uid, id, {'credit_note': True}, context=context)
|
||||
self.compute_sheet(cr, uid, [id_copy], context=context)
|
||||
wf_service.trg_validate(uid, 'hr.payslip', id_copy, 'verify_sheet', cr)
|
||||
wf_service.trg_validate(uid, 'hr.payslip', id_copy, 'final_verify_sheet', cr)
|
||||
wf_service.trg_validate(uid, 'hr.payslip', id_copy, 'hr_verify_sheet', cr)
|
||||
wf_service.trg_validate(uid, 'hr.payslip', id_copy, 'process_sheet', cr)
|
||||
|
||||
form_id = mod_obj.get_object_reference(cr, uid, 'hr_payroll', 'view_hr_payslip_form')
|
||||
|
@ -345,8 +337,8 @@ class hr_payslip(osv.osv):
|
|||
'context': {}
|
||||
}
|
||||
|
||||
def verify_sheet(self, cr, uid, ids, context=None):
|
||||
return self.write(cr, uid, ids, {'state': 'confirm'}, context=context)
|
||||
def check_done(self, cr, uid, ids, context=None):
|
||||
return True
|
||||
|
||||
#TODO move this function into hr_contract module, on hr.employee object
|
||||
def get_contract(self, cr, uid, employee, date_from, date_to, context=None):
|
||||
|
@ -490,9 +482,9 @@ class hr_payslip(osv.osv):
|
|||
if to_date is None:
|
||||
to_date = datetime.now().strftime('%Y-%m-%d')
|
||||
result = 0.0
|
||||
self.cr.execute("SELECT sum(quantity) as sum\
|
||||
self.cr.execute("SELECT sum(amount) as sum\
|
||||
FROM hr_payslip as hp, hr_payslip_input as pi \
|
||||
WHERE hp.employee_id = %s AND hp.state in ('confirm','done') \
|
||||
WHERE hp.employee_id = %s AND hp.state = 'done' \
|
||||
AND hp.date_from >= %s AND hp.date_to <= %s AND hp.id = pi.payslip_id AND pi.code = %s",
|
||||
(self.employee_id, from_date, to_date, code))
|
||||
res = self.cr.fetchone()[0]
|
||||
|
@ -506,7 +498,7 @@ class hr_payslip(osv.osv):
|
|||
result = 0.0
|
||||
self.cr.execute("SELECT sum(number_of_days) as number_of_days, sum(number_of_hours) as number_of_hours\
|
||||
FROM hr_payslip as hp, hr_payslip_worked_days as pi \
|
||||
WHERE hp.employee_id = %s AND hp.state in ('confirm','done') \
|
||||
WHERE hp.employee_id = %s AND hp.state = 'done'\
|
||||
AND hp.date_from >= %s AND hp.date_to <= %s AND hp.id = pi.payslip_id AND pi.code = %s",
|
||||
(self.employee_id, from_date, to_date, code))
|
||||
return self.cr.fetchone()
|
||||
|
@ -527,7 +519,7 @@ class hr_payslip(osv.osv):
|
|||
to_date = datetime.now().strftime('%Y-%m-%d')
|
||||
self.cr.execute("SELECT sum(case when hp.credit_note = False then (pl.total) else (-pl.total) end)\
|
||||
FROM hr_payslip as hp, hr_payslip_line as pl \
|
||||
WHERE hp.employee_id = %s AND hp.state in ('confirm','done') \
|
||||
WHERE hp.employee_id = %s AND hp.state = 'done' \
|
||||
AND hp.date_from >= %s AND hp.date_to <= %s AND hp.id = pl.slip_id AND pl.code = %s",
|
||||
(self.employee_id, from_date, to_date, code))
|
||||
res = self.cr.fetchone()
|
||||
|
@ -727,13 +719,13 @@ class hr_payslip_input(osv.osv):
|
|||
'payslip_id': fields.many2one('hr.payslip', 'Pay Slip', required=True),
|
||||
'sequence': fields.integer('Sequence', required=True,),
|
||||
'code': fields.char('Code', size=52, required=True, help="The code that can be used in the salary rules"),
|
||||
'quantity': fields.float('Quantity', help="It is used in computation. For e.g. A rule for sales having 1% commission of basic salary for per product can defined in expression like result = inputs.SASUS.qunatity * contract.wage*0.01."),
|
||||
'amount': fields.float('Amount', help="It is used in computation. For e.g. A rule for sales having 1% commission of basic salary for per product can defined in expression like result = inputs.SALEURO.amount * contract.wage*0.01."),
|
||||
'contract_id': fields.many2one('hr.contract', 'Contract', required=True, help="The contract for which applied this input"),
|
||||
}
|
||||
_order = 'payslip_id, sequence'
|
||||
_defaults = {
|
||||
'sequence': 10,
|
||||
'quantity': 0.0,
|
||||
'amount': 0.0,
|
||||
}
|
||||
|
||||
hr_payslip_input()
|
||||
|
|
|
@ -67,7 +67,7 @@
|
|||
<field name="category_id" ref="hr_payroll.ALW"/>
|
||||
<field name="name">Get 1% of sales</field>
|
||||
<field name="sequence" eval="17"/>
|
||||
<field name="amount_python_compute">result = (inputs.SALEURO.quantity + inputs.SALASIA.quantity) * contract.wage * 0.01</field>
|
||||
<field name="amount_python_compute">result = (inputs.SALEURO.amount + inputs.SALASIA.amount) * contract.wage * 0.01</field>
|
||||
</record>
|
||||
|
||||
<!-- Rule Inputs -->
|
||||
|
|
|
@ -298,7 +298,7 @@
|
|||
<tree string="Input Data" editable="bottom">
|
||||
<field name="name"/>
|
||||
<field name="code"/>
|
||||
<field name="quantity"/>
|
||||
<field name="amount"/>
|
||||
<field name="contract_id" groups="base.group_extended"/>
|
||||
<field name="sequence" invisible="True"/>
|
||||
</tree>
|
||||
|
@ -308,7 +308,7 @@
|
|||
<field name="code" select="1"/>
|
||||
<field name="payslip_id"/>
|
||||
<field name="sequence" groups="base.group_extended"/>
|
||||
<field name="quantity"/>
|
||||
<field name="amount"/>
|
||||
<field name="contract_id" groups="base.group_extended"/>
|
||||
</group>
|
||||
</form>
|
||||
|
@ -330,13 +330,11 @@
|
|||
</notebook>
|
||||
<group col="10" colspan="4">
|
||||
<field name="state"/>
|
||||
<button string="Cancel" icon="terp-dialog-close" name="cancel_sheet" states="draft,hr_check,confirm"/>
|
||||
<button string="Cancel" icon="terp-dialog-close" name="cancel_sheet" states="draft,hr_check,confirm,verify"/>
|
||||
<button string="Compute Sheet" icon="terp-stock_format-scientific" name="compute_sheet" type="object" states="draft"/>
|
||||
<button string="Verify Sheet" icon="terp-camera_test" name="verify_sheet" states="draft"/>
|
||||
<button string="Approve Sheet" icon="terp-camera_test" name="final_verify_sheet" states="hr_check"/>
|
||||
<button string="Pay Salary" icon="terp-dolar_ok!" name="process_sheet" states="confirm"/>
|
||||
<button string="Set to Draft" icon="terp-stock_effects-object-colorize" name="draft" states="cancel"/>
|
||||
<button string="Refund" icon="gtk-execute" name="refund_sheet" states="confirm,done" type='object'/>
|
||||
<button string="Confirm" icon="terp-camera_test" name="hr_verify_sheet" states="draft"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
|
|
|
@ -14,20 +14,12 @@
|
|||
<field name="kind">function</field>
|
||||
<field name="action">write({'state': 'draft'})</field>
|
||||
<field name="split_mode">OR</field>
|
||||
|
||||
</record>
|
||||
|
||||
<record id="act_hr_check" model="workflow.activity">
|
||||
<record id="act_verify" model="workflow.activity">
|
||||
<field name="wkf_id" ref="wkf"/>
|
||||
<field name="name">hr_check</field>
|
||||
<field name="action">hr_check_sheet()</field>
|
||||
<field name="kind">function</field>
|
||||
</record>
|
||||
|
||||
<record id="act_confirm" model="workflow.activity">
|
||||
<field name="wkf_id" ref="wkf"/>
|
||||
<field name="name">confirm</field>
|
||||
<field name="action">verify_sheet()</field>
|
||||
<field name="name">verify</field>
|
||||
<field name="action">hr_verify_sheet()</field>
|
||||
<field name="kind">function</field>
|
||||
</record>
|
||||
|
||||
|
@ -46,52 +38,35 @@
|
|||
<field name="flow_stop">True</field>
|
||||
</record>
|
||||
|
||||
<record id="t1" model="workflow.transition">
|
||||
<field name="act_from" ref="act_draft"/>
|
||||
<field name="act_to" ref="act_verify"/>
|
||||
<field name="signal">hr_verify_sheet</field>
|
||||
</record>
|
||||
|
||||
<record id="t2" model="workflow.transition">
|
||||
<field name="act_from" ref="act_draft"/>
|
||||
<field name="act_to" ref="act_hr_check"/>
|
||||
<field name="signal">verify_sheet</field>
|
||||
</record>
|
||||
|
||||
<record id="t3" model="workflow.transition">
|
||||
<field name="act_from" ref="act_hr_check"/>
|
||||
<field name="act_to" ref="act_confirm"/>
|
||||
<field name="signal">final_verify_sheet</field>
|
||||
</record>
|
||||
|
||||
<record id="t4" model="workflow.transition">
|
||||
<field name="act_from" ref="act_confirm"/>
|
||||
<field name="act_to" ref="act_done"/>
|
||||
<field name="signal">process_sheet</field>
|
||||
</record>
|
||||
|
||||
<record id="t7" model="workflow.transition">
|
||||
<field name="act_from" ref="act_draft"/>
|
||||
<field name="act_to" ref="act_cancel"/>
|
||||
<field name="signal">cancel_sheet</field>
|
||||
</record>
|
||||
|
||||
<record id="t8" model="workflow.transition">
|
||||
<field name="act_from" ref="act_hr_check"/>
|
||||
<field name="act_to" ref="act_cancel"/>
|
||||
<field name="signal">cancel_sheet</field>
|
||||
</record>
|
||||
|
||||
<record id="t9" model="workflow.transition">
|
||||
<field name="act_from" ref="act_confirm"/>
|
||||
<field name="act_to" ref="act_cancel"/>
|
||||
<field name="signal">cancel_sheet</field>
|
||||
</record>
|
||||
|
||||
<record id="t11" model="workflow.transition">
|
||||
<field name="act_from" ref="act_done"/>
|
||||
<field name="act_to" ref="act_cancel"/>
|
||||
<field name="signal">cancel_sheet</field>
|
||||
</record>
|
||||
|
||||
<record id="t12" model="workflow.transition">
|
||||
|
||||
<record id="t3" model="workflow.transition">
|
||||
<field name="act_from" ref="act_cancel"/>
|
||||
<field name="act_to" ref="act_draft"/>
|
||||
<field name="signal">draft</field>
|
||||
</record>
|
||||
|
||||
<record id="t4" model="workflow.transition">
|
||||
<field name="act_from" ref="act_verify"/>
|
||||
<field name="act_to" ref="act_cancel"/>
|
||||
<field name="signal">cancel_sheet</field>
|
||||
</record>
|
||||
|
||||
<record id="t5" model="workflow.transition">
|
||||
<field name="act_from" ref="act_verify"/>
|
||||
<field name="act_to" ref="act_done"/>
|
||||
<field name="condition">check_done()</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
Loading…
Reference in New Issue