From fd50df3934906903452cfe0dce037f9a38541fbe Mon Sep 17 00:00:00 2001 From: vra Date: Thu, 14 Oct 2010 17:36:38 +0530 Subject: [PATCH] [IMP][ADD] hr_payroll_account: added differents account fields in all hr payroll objects including demo with some improvement. bzr revid: vra@tinyerp.com-20101014120638-1gsqtz0lm2mf3xe7 --- addons/hr_payroll_account/__openerp__.py | 2 + .../hr_payroll_account/hr_payroll_account.py | 178 ++++++++++- .../hr_payroll_account_view.xml | 287 +++++++++++++++--- addons/hr_payroll_account/hr_payroll_demo.xml | 60 ++++ 4 files changed, 481 insertions(+), 46 deletions(-) create mode 100644 addons/hr_payroll_account/hr_payroll_demo.xml diff --git a/addons/hr_payroll_account/__openerp__.py b/addons/hr_payroll_account/__openerp__.py index 5dec5dc4fb8..97ae94a361c 100644 --- a/addons/hr_payroll_account/__openerp__.py +++ b/addons/hr_payroll_account/__openerp__.py @@ -33,6 +33,7 @@ 'depends': [ 'hr_payroll', 'account', + 'hr_expense' ], 'init_xml': [ ], @@ -40,6 +41,7 @@ "hr_payroll_account_view.xml", ], 'demo_xml': [ + 'hr_payroll_demo.xml' ], 'installable': True, 'active': False, diff --git a/addons/hr_payroll_account/hr_payroll_account.py b/addons/hr_payroll_account/hr_payroll_account.py index 87b76895e1a..dcef94c3f35 100644 --- a/addons/hr_payroll_account/hr_payroll_account.py +++ b/addons/hr_payroll_account/hr_payroll_account.py @@ -42,6 +42,172 @@ def prev_bounds(cdate=False): prev_end = next_month - timedelta(days=1) return this_first, prev_end +class hr_payroll_structure(osv.osv): + _inherit = 'hr.payroll.structure' + _description = 'Salary Structure' + + _columns = { + 'account_id':fields.many2one('account.analytic.account', 'Analytic Account'), + } +hr_payroll_structure() + +class hr_employee(osv.osv): + ''' + Employee + ''' + _inherit = 'hr.employee' + _description = 'Employee' + + _columns = { + 'property_bank_account': fields.property( + 'account.account', + type='many2one', + relation='account.account', + string="Bank Account", + method=True, + domain="[('type', '=', 'liquidity')]", + view_load=True, + help="Select Bank Account from where Salary Expanse will be Paid"), + 'salary_account':fields.property( + 'account.account', + type='many2one', + relation='account.account', + string="Salary Account", + method=True, + domain="[('type', '=', 'other')]", + view_load=True, + help="Expanse account when Salary Expanse will be recorded"), + 'employee_account':fields.property( + 'account.account', + type='many2one', + relation='account.account', + string="Employee Account", + method=True, + domain="[('type', '=', 'other')]", + view_load=True, + help="Employee Payable Account"), + 'analytic_account':fields.property( + 'account.analytic.account', + type='many2one', + relation='account.analytic.account', + string="Analytic Account", + method=True, + view_load=True, + help="Analytic Account for Salary Analysis"), + } +hr_employee() + +class payroll_register(osv.osv): + _inherit = 'hr.payroll.register' + _description = 'Payroll Register' + + _columns = { + 'journal_id': fields.many2one('account.journal', 'Expanse Journal'), + 'bank_journal_id': fields.many2one('account.journal', 'Bank Journal'), + 'period_id': fields.many2one('account.period', 'Force Period', domain=[('state','<>','done')], help="Keep empty to use the period of the validation(Payslip) date."), + } + + def compute_sheet(self, cr, uid, ids, context={}): + emp_pool = self.pool.get('hr.employee') + slip_pool = self.pool.get('hr.payslip') + func_pool = self.pool.get('hr.payroll.structure') + slip_line_pool = self.pool.get('hr.payslip.line') + wf_service = netsvc.LocalService("workflow") + vals = self.browse(cr, uid, ids)[0] + emp_ids = emp_pool.search(cr, uid, []) + + for emp in emp_pool.browse(cr, uid, emp_ids): + old_slips = slip_pool.search(cr, uid, [('employee_id','=', emp.id), ('date','=',vals.date)]) + if old_slips: + slip_pool.write(cr, uid, old_slips, {'register_id':ids[0]}) + for sid in old_slips: + wf_service.trg_validate(uid, 'hr.payslip', sid, 'compute_sheet', cr) + else: + res = { + 'employee_id':emp.id, + 'basic':0.0, + 'register_id':ids[0], + 'name':vals.name, + 'date':vals.date, + 'journal_id':vals.journal_id.id, + 'bank_journal_id':vals.bank_journal_id.id + } + slip_id = slip_pool.create(cr, uid, res) + wf_service.trg_validate(uid, 'hr.payslip', slip_id, 'compute_sheet', cr) + + number = self.pool.get('ir.sequence').get(cr, uid, 'salary.register') + self.write(cr, uid, ids, {'state':'draft', 'number':number}) + return True + +payroll_register() + +class payroll_advice(osv.osv): + _inherit = 'hr.payroll.advice' + _description = 'Bank Advice Note' + + _columns = { + 'account_id': fields.many2one('account.account', 'Account'), + } +payroll_advice() + +class contrib_register(osv.osv): + _inherit = 'hr.contibution.register' + _description = 'Contribution Register' + + def _total_contrib(self, cr, uid, ids, field_names, arg, context={}): + line_pool = self.pool.get('hr.contibution.register.line') + period_id = self.pool.get('account.period').search(cr,uid,[('date_start','<=',time.strftime('%Y-%m-%d')),('date_stop','>=',time.strftime('%Y-%m-%d'))])[0] + fiscalyear_id = self.pool.get('account.period').browse(cr, uid, period_id).fiscalyear_id + res = {} + for cur in self.browse(cr, uid, ids): + current = line_pool.search(cr, uid, [('period_id','=',period_id),('register_id','=',cur.id)]) + years = line_pool.search(cr, uid, [('period_id.fiscalyear_id','=',fiscalyear_id.id), ('register_id','=',cur.id)]) + + e_month = 0.0 + c_month = 0.0 + for i in line_pool.browse(cr, uid, current): + e_month += i.emp_deduction + c_month += i.comp_deduction + + e_year = 0.0 + c_year = 0.0 + for j in line_pool.browse(cr, uid, years): + e_year += i.emp_deduction + c_year += i.comp_deduction + + res[cur.id]={ + 'monthly_total_by_emp':e_month, + 'monthly_total_by_comp':c_month, + 'yearly_total_by_emp':e_year, + 'yearly_total_by_comp':c_year + } + return res + + _columns = { + 'account_id': fields.many2one('account.account', 'Account'), + 'analytic_account_id':fields.many2one('account.analytic.account', 'Analytic Account'), + 'yearly_total_by_emp': fields.function(_total_contrib, method=True, multi='dc', store=True, string='Total By Employee', digits=(16, 4)), + 'yearly_total_by_comp': fields.function(_total_contrib, method=True, multi='dc', store=True, string='Total By Company', digits=(16, 4)), + } +contrib_register() + +class contrib_register_line(osv.osv): + _inherit = 'hr.contibution.register.line' + _description = 'Contribution Register Line' + + _columns = { + 'period_id': fields.many2one('account.period', 'Period'), + } +contrib_register_line() + +class hr_holidays_status(osv.osv): + _inherit = 'hr.holidays.status' + _columns = { + 'account_id': fields.many2one('account.account', 'Account'), + 'analytic_account_id':fields.many2one('account.analytic.account', 'Analytic Account'), + } +hr_holidays_status() + class hr_payslip(osv.osv): ''' Pay Slip @@ -50,7 +216,9 @@ class hr_payslip(osv.osv): _description = 'Pay Slip' _columns = { - 'move_ids':fields.one2many('hr.payslip.account.move', 'slip_id', 'Accounting vouchers', required=False), + 'journal_id': fields.many2one('account.journal', 'Expanse Journal'), + 'bank_journal_id': fields.many2one('account.journal', 'Bank Journal'), + 'move_ids':fields.one2many('hr.payslip.account.move', 'slip_id', 'Accounting vouchers'), 'move_line_ids':fields.many2many('account.move.line', 'payslip_lines_rel', 'slip_id', 'line_id', 'Accounting Lines', readonly=True), 'move_payment_ids':fields.many2many('account.move.line', 'payslip_payment_rel', 'slip_id', 'payment_id', 'Payment Lines', readonly=True), 'period_id': fields.many2one('account.period', 'Force Period', domain=[('state','<>','done')], help="Keep empty to use the period of the validation(Payslip) date."), @@ -479,6 +647,14 @@ class hr_payslip(osv.osv): hr_payslip() +class hr_payslip_line(osv.osv): + _inherit = 'hr.payslip.line' + _columns = { + 'account_id': fields.many2one('account.account', 'General Account'), + 'analytic_account_id':fields.many2one('account.analytic.account', 'Analytic Account'), + } +hr_payslip_line() + class account_move_link_slip(osv.osv): ''' Account Move Link to Pay Slip diff --git a/addons/hr_payroll_account/hr_payroll_account_view.xml b/addons/hr_payroll_account/hr_payroll_account_view.xml index 6ef6c812c0b..a7277432cf3 100644 --- a/addons/hr_payroll_account/hr_payroll_account_view.xml +++ b/addons/hr_payroll_account/hr_payroll_account_view.xml @@ -1,61 +1,258 @@ - - - hr.payslip.form + + + hr.hr.employee.view.form2.inherit_1 + hr.employee + form + + + + + + + + + + + + + + + + hr.hr.employee.view.form2.inherit + hr.employee + form + + + + + + + + + + + + + + + hr.holidays.status.inherit1 + hr.holidays.status + + form + + + + + + + + + + hr.payslip.line.inherit.tree + hr.payslip.line + + tree + + + + + + + + + + hr.payslip.line.inherit.form + hr.payslip.line + + form + + + + + + + + + + hr.payslip.inherit.form + hr.payslip + + form + + + + + + + + + + + hr.payslip.form.inherit1 hr.payslip form - - - - - - - - - - -
- - - - - -
- - - - - - - - - - -
-
+ + + + + + + +
- - - hr.payslip.form - hr.payslip + + + hr.payroll.advice.inherit.form + hr.payroll.advice + form - - - - - - - - - + + + + + + hr.payroll.register.inherit.tree + hr.payroll.register + + tree + + + + + + + + + + hr.payroll.register.inherit.form + hr.payroll.register + + form + + + + + + + + + + hr.contibution.register.inherit.tree + hr.contibution.register + + tree + + + + + + + + + + hr.contibution.register.inherit.form + hr.contibution.register + + form + + + + + + + + + + hr.contibution.register.inherit1.form + hr.contibution.register + + form + + + + + + + + + + + + + hr.contibution.register.line.form.inherit + hr.contibution.register.line + + form + + + + + + + + + hr.payslip.form + hr.payslip + form + + + + + + + + + + + + +
+ + + + + +
+ + + + + + + + + + +
+
+
+
+ + + hr.payslip.form + hr.payslip + form + + + + + + + + + + + +
diff --git a/addons/hr_payroll_account/hr_payroll_demo.xml b/addons/hr_payroll_account/hr_payroll_demo.xml new file mode 100644 index 00000000000..3aecf5455c5 --- /dev/null +++ b/addons/hr_payroll_account/hr_payroll_demo.xml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +