[MERGE] Corrected the payslip approval if proper configuration is missing
bzr revid: jvo@tinyerp.com-20110302100328-4y94qos6uu6xta2t
This commit is contained in:
commit
1cf4261d0f
|
@ -148,7 +148,7 @@ class hr_employee(osv.osv):
|
|||
'address_id': fields.many2one('res.partner.address', 'Working Address'),
|
||||
'address_home_id': fields.many2one('res.partner.address', 'Home Address'),
|
||||
'partner_id': fields.related('address_home_id', 'partner_id', type='many2one', relation='res.partner', readonly=True, help="Partner that is related to the current employee. Accounting transaction will be written on this partner belongs to employee."),
|
||||
'bank_account_id':fields.many2one('res.partner.bank', 'Bank Account', domain="[('partner_id','=',partner_id)]", help="Employee bank salary account"),
|
||||
'bank_account_id':fields.many2one('res.partner.bank', 'Bank Account Number', domain="[('partner_id','=',partner_id)]", help="Employee bank salary account"),
|
||||
'work_phone': fields.char('Work Phone', size=32, readonly=False),
|
||||
'mobile_phone': fields.char('Mobile', size=32, readonly=False),
|
||||
'work_email': fields.char('Work E-mail', size=240),
|
||||
|
|
|
@ -64,7 +64,7 @@ class hr_employee(osv.osv):
|
|||
method=True,
|
||||
domain="[('type', '=', 'liquidity')]",
|
||||
view_load=True,
|
||||
help="Select Bank Account from where Salary Expense will be Paid"),
|
||||
help="Select Bank Account from where Salary Expense will be Paid, to be used for payslip verification."),
|
||||
'salary_account':fields.property(
|
||||
'account.account',
|
||||
type='many2one',
|
||||
|
@ -295,6 +295,10 @@ class hr_payslip(osv.osv):
|
|||
self.create_voucher(cr, uid, [slip.id], name, move_id)
|
||||
|
||||
name = "To %s account" % (slip.employee_id.name)
|
||||
|
||||
if not slip.employee_id.property_bank_account.id:
|
||||
raise osv.except_osv(_('Warning !'), _('Employee Bank Account is not defined for %s') % slip.employee_id.name)
|
||||
|
||||
ded_rec = {
|
||||
'move_id': move_id,
|
||||
'name': name,
|
||||
|
@ -426,10 +430,10 @@ class hr_payslip(osv.osv):
|
|||
partner_id = False
|
||||
|
||||
if not slip.employee_id.bank_account_id:
|
||||
raise osv.except_osv(_('Integrity Error !'), _('Please defined bank account for %s !') % (slip.employee_id.name))
|
||||
raise osv.except_osv(_('Configuration Error !'), _('Please define bank account for %s !') % (slip.employee_id.name))
|
||||
|
||||
if not slip.employee_id.bank_account_id.partner_id:
|
||||
raise osv.except_osv(_('Integrity Error !'), _('Please defined partner in bank account for %s !') % (slip.employee_id.name))
|
||||
raise osv.except_osv(_('Configuration Error !'), _('Please define partner in bank account for %s !') % (slip.employee_id.name))
|
||||
|
||||
partner = slip.employee_id.bank_account_id.partner_id
|
||||
partner_id = slip.employee_id.bank_account_id.partner_id.id
|
||||
|
@ -463,7 +467,10 @@ class hr_payslip(osv.osv):
|
|||
}
|
||||
move_id = move_pool.create(cr, uid, move, context=context)
|
||||
self.create_voucher(cr, uid, [slip.id], slip.name, move_id)
|
||||
|
||||
|
||||
if not slip.employee_id.salary_account.id:
|
||||
raise osv.except_osv(_('Warning !'), _('Please define Salary Account for %s.') % slip.employee_id.name)
|
||||
|
||||
line = {
|
||||
'move_id':move_id,
|
||||
'name': "By Basic Salary / " + slip.employee_id.name,
|
||||
|
@ -477,7 +484,6 @@ class hr_payslip(osv.osv):
|
|||
'analytic_account_id': False,
|
||||
'ref':slip.number
|
||||
}
|
||||
|
||||
#Setting Analysis Account for Basic Salary
|
||||
if slip.employee_id.analytic_account:
|
||||
line['analytic_account_id'] = slip.employee_id.analytic_account.id
|
||||
|
@ -485,9 +491,12 @@ class hr_payslip(osv.osv):
|
|||
move_line_id = movel_pool.create(cr, uid, line, context=context)
|
||||
line_ids += [move_line_id]
|
||||
|
||||
if not slip.employee_id.employee_account.id:
|
||||
raise osv.except_osv(_('Warning !'), _('Please define Employee Payable Account for %s.') % slip.employee_id.name)
|
||||
|
||||
line = {
|
||||
'move_id':move_id,
|
||||
'name': "To Basic Paysble Salary / " + slip.employee_id.name,
|
||||
'name': "To Basic Payable Salary / " + slip.employee_id.name,
|
||||
'partner_id': partner_id,
|
||||
'date': slip.date,
|
||||
'account_id': slip.employee_id.employee_account.id,
|
||||
|
@ -498,6 +507,7 @@ class hr_payslip(osv.osv):
|
|||
'period_id': period_id,
|
||||
'ref':slip.number
|
||||
}
|
||||
|
||||
line_ids += [movel_pool.create(cr, uid, line, context=context)]
|
||||
|
||||
for line in slip.line_ids:
|
||||
|
@ -530,7 +540,7 @@ class hr_payslip(osv.osv):
|
|||
if line.type == 'allowance' or line.type == 'otherpay':
|
||||
rec['debit'] = amount
|
||||
if not partner.property_account_payable:
|
||||
raise osv.except_osv(_('Integrity Error !'), _('Please Configure Partners Payable Account!!'))
|
||||
raise osv.except_osv(_('Configuration Error !'), _('Please Configure Partners Payable Account!!'))
|
||||
ded_rec = {
|
||||
'move_id': move_id,
|
||||
'name': name,
|
||||
|
@ -547,7 +557,7 @@ class hr_payslip(osv.osv):
|
|||
line_ids += [movel_pool.create(cr, uid, ded_rec, context=context)]
|
||||
elif line.type == 'deduction' or line.type == 'otherdeduct':
|
||||
if not partner.property_account_receivable:
|
||||
raise osv.except_osv(_('Integrity Error !'), _('Please Configure Partners Receivable Account!!'))
|
||||
raise osv.except_osv(_('Configuration Error !'), _('Please Configure Partners Receivable Account!!'))
|
||||
rec['credit'] = amount
|
||||
total_deduct += amount
|
||||
ded_rec = {
|
||||
|
|
|
@ -221,5 +221,22 @@
|
|||
</notebook>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Adding Account Properties to the Employee form -->
|
||||
|
||||
<record id="hr_employee_payroll_property_form" model="ir.ui.view">
|
||||
<field name="name">hr.employee.payroll.property.form</field>
|
||||
<field name="model">hr.employee</field>
|
||||
<field name="inherit_id" ref="hr_contract.hr_hr_employee_view_form2"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="bank_account_id" position="after">
|
||||
<field name="property_bank_account" string="Employee Bank Account"/>
|
||||
<field name="salary_account"/>
|
||||
<field name="employee_account"/>
|
||||
<field name="analytic_account"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
Loading…
Reference in New Issue