← Back to team overview

openerp-dev-web team mailing list archive

[Merge] lp:~openerp-dev/openobject-addons/trunk-payroll-account-mtr into lp:~openerp-dev/openobject-addons/trunk-payroll

 

Meera Trambadia (OpenERP) has proposed merging lp:~openerp-dev/openobject-addons/trunk-payroll-account-mtr into lp:~openerp-dev/openobject-addons/trunk-payroll.

Requested reviews:
  qdp (OpenERP) (qdp)
  Mustufa Rangwala (Open ERP) (mra-tinyerp)
Related bugs:
  Bug #761456 in OpenERP Addons: "[trunk] hr_payroll_account: Domain mismatch between Employee Account in the employee record and payable account in partner record"
  https://bugs.launchpad.net/openobject-addons/+bug/761456

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-payroll-account-mtr/+merge/60745

The following improvements has been made in hr_payroll_account:-
-> employee's contract: analytic account. + journal (with onchange on the journal of payslip)
-> contribution register: add a account.journal and an analytic account
-> salary rule: account.accoutns (for the debit and credit side) and account.analytic.account and an accuont.tax.code
-> payslip: accuont.period and account.move (m2m)
-> account.journal on the payslip (if account.Account empty in the salary rule use the default ones of it)
-> changed domain and ir.property to make account type=payable for employee account
-> improved code to create Accounting Entries
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-payroll-account-mtr/+merge/60745
Your team OpenERP R&D Team is subscribed to branch lp:~openerp-dev/openobject-addons/trunk-payroll.
=== modified file 'hr_payroll/hr_payroll.py'
--- hr_payroll/hr_payroll.py	2011-05-12 09:00:09 +0000
+++ hr_payroll/hr_payroll.py	2011-05-12 09:30:57 +0000
@@ -370,7 +370,9 @@
 
     def compute_sheet(self, cr, uid, ids, context=None):
         slip_line_pool = self.pool.get('hr.payslip.line')
+        sequence_obj = self.pool.get('ir.sequence')
         for payslip in self.browse(cr, uid, ids, context=context):
+            number = sequence_obj.get(cr, uid, 'salary.slip')
             #delete old payslip lines
             old_slipline_ids = slip_line_pool.search(cr, uid, [('slip_id', '=', payslip.id)], context=context)
 #            old_slipline_ids
@@ -383,7 +385,7 @@
                 #if we don't give the contract, then the rules to apply should be for all current contracts of the employee
                 contract_ids = self.get_contract(cr, uid, payslip.employee_id, payslip.date_from, payslip.date_to, context=context)
             lines = [(0,0,line) for line in self.pool.get('hr.payslip').get_payslip_lines(cr, uid, contract_ids, payslip.id, context=context)]
-            self.write(cr, uid, [payslip.id], {'line_ids': lines}, context=context)
+            self.write(cr, uid, [payslip.id], {'line_ids': lines, 'number': number,}, context=context)
         return True
 
     def get_worked_day_lines(self, cr, uid, contract_ids, date_from, date_to, context=None):

=== modified file 'hr_payroll_account/__openerp__.py'
--- hr_payroll_account/__openerp__.py	2011-03-18 14:06:18 +0000
+++ hr_payroll_account/__openerp__.py	2011-05-12 09:30:57 +0000
@@ -46,7 +46,7 @@
         "hr_payroll_account_view.xml",
     ],
     'demo_xml': [
-        'hr_payroll_demo.xml'
+        'hr_payroll_account_demo.xml'
     ],
     'installable': True,
     'active': False,

=== modified file 'hr_payroll_account/hr_payroll_account.py'
--- hr_payroll_account/hr_payroll_account.py	2011-03-02 10:44:41 +0000
+++ hr_payroll_account/hr_payroll_account.py	2011-05-12 09:30:57 +0000
@@ -27,17 +27,17 @@
 from tools import config
 from tools.translate import _
 
-def prev_bounds(cdate=False):
-    when = date.fromtimestamp(time.mktime(time.strptime(cdate,"%Y-%m-%d")))
-    this_first = date(when.year, when.month, 1)
-    month = when.month + 1
-    year = when.year
-    if month > 12:
-        month = 1
-        year += 1
-    next_month = date(year, month, 1)
-    prev_end = next_month - timedelta(days=1)
-    return this_first, prev_end
+#def prev_bounds(cdate=False):
+#    when = date.fromtimestamp(time.mktime(time.strptime(cdate,"%Y-%m-%d")))
+#    this_first = date(when.year, when.month, 1)
+#    month = when.month + 1
+#    year = when.year
+#    if month > 12:
+#        month = 1
+#        year += 1
+#    next_month = date(year, month, 1)
+#    prev_end = next_month - timedelta(days=1)
+#    return this_first, prev_end
 
 class hr_payroll_structure(osv.osv):
     _inherit = 'hr.payroll.structure'
@@ -80,7 +80,7 @@
             relation='account.account',
             string="Employee Account",
             method=True,
-            domain="[('type', '=', 'other')]",
+            domain="[('type', '=', 'payable')]",
             view_load=True,
             help="Employee Payable Account"),
         'analytic_account':fields.property(
@@ -94,90 +94,90 @@
     }
 hr_employee()
 
-class payroll_register(osv.osv):
-    _inherit = 'hr.payroll.register'
-    _description = 'Payroll Register'
-
-    _columns = {
-        'journal_id': fields.many2one('account.journal', 'Expense 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=None):
-        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, context=context)[0]
-        emp_ids = emp_pool.search(cr, uid, [])
-
-        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)])
-            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 payroll_register(osv.osv):
+#    _inherit = 'hr.payroll.register'
+#    _description = 'Payroll Register'
+#
+#    _columns = {
+#        'journal_id': fields.many2one('account.journal', 'Expense 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=None):
+#        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, context=context)[0]
+#        emp_ids = emp_pool.search(cr, uid, [])
+#
+#        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)])
+#            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'
+    _inherit = 'hr.contribution.register'
     _description = 'Contribution Register'
 
     def _total_contrib(self, cr, uid, ids, field_names, arg, context=None):
-        line_pool = self.pool.get('hr.contibution.register.line')
+#        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, context=context).fiscalyear_id
         res = {}
-        for cur in self.browse(cr, uid, ids, context=context):
-            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, context=context):
-                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, context=context):
-                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
-            }
+#        for cur in self.browse(cr, uid, ids, context=context):
+#            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, context=context):
+#                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, context=context):
+#                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 = {
@@ -188,22 +188,22 @@
     }
 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 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):
     '''
@@ -213,14 +213,72 @@
     _description = 'Pay Slip'
 
     _columns = {
-        'journal_id': fields.many2one('account.journal', 'Expense Journal'),
-        'bank_journal_id': fields.many2one('account.journal', 'Bank Journal'),
+        'journal_id': fields.many2one('account.journal', 'Expense Journal',states={'draft': [('readonly', False)]}, readonly=True),
+        'bank_journal_id': fields.many2one('account.journal', 'Bank Journal', states={'draft': [('readonly', False)]}, readonly=True),
         '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."),
+        'period_id': fields.many2one('account.period', 'Force Period',states={'draft': [('readonly', False)]}, readonly=True, domain=[('state','<>','done')], help="Keep empty to use the period of the validation(Payslip) date."),
+        'account_move_ids': fields.many2many('account.move', 'payslip_move_rel', 'slip_id', 'move_id', 'Accounting Entries', readonly=True),
     }
 
+    def onchange_contract_id(self, cr, uid, ids, date_from, date_to, employee_id=False, contract_id=False, context=None):
+        contract_obj = self.pool.get('hr.contract')
+        res = super(hr_payslip, self).onchange_contract_id(cr, uid, ids, date_from=date_from, date_to=date_to, employee_id=employee_id, contract_id=contract_id, context=context)
+        journal_id = contract_obj.browse(cr, uid, contract_id, context=context).journal_id.id
+        res['value'].update({'journal_id': journal_id})
+        return res
+
+#    def onchange_employee_id(self, cr, uid, ids, date_from, date_to, employee_id=False, contract_id=False, context=None):
+#        contract_obj = self.pool.get('hr.contract')
+#        res = super(hr_payslip, self).onchange_employee_id(cr, uid, ids, date_from=date_from, date_to=date_to, employee_id=employee_id, contract_id=contract_id, context=context)
+#        contract_id = res['value']['contract_id']
+#        if res['value']['contract_id']:
+#            journal_id = contract_obj.browse(cr, uid, res['value']['contract_id'], context=context).journal_id.id
+#            res['value'].update({'journal_id': journal_id})
+#        return res
+
+    def get_payslip_lines(self, cr, uid, contract_ids, payslip_id, context):
+        journal_obj = self.pool.get('account.journal')
+        rule_obj = self.pool.get('hr.salary.rule')
+        contract_obj = self.pool.get('hr.contract')
+        structure_obj = self.pool.get('hr.payroll.structure')
+        vals_account = {}
+        result = super(hr_payslip, self).get_payslip_lines(cr, uid, contract_ids, payslip_id, context)
+        structure_ids = contract_obj.get_all_structures(cr, uid, contract_ids, context=context)
+        #get the rules of the structure and thier children
+        rule_ids = structure_obj.get_all_rules(cr, uid, structure_ids, context=context)
+        sorted_rule_ids = [id for id, sequence in sorted(rule_ids, key=lambda x:x[1])]
+        #Fetching Debit/Credit account of the payslip journal. 
+        journal = self.browse(cr, uid, payslip_id, context=context).journal_id
+        credit_account = journal.default_credit_account_id and journal.default_credit_account_id.id or False
+        debit_account = journal.default_debit_account_id and journal.default_debit_account_id.id or False
+        # Assigning above fetched Debit/Credit account on salary rules if not specified 
+        for rule in rule_obj.browse(cr, uid, sorted_rule_ids, context=context):
+            if not rule.account_debit.id:
+                rule_obj.write(cr, uid, [rule.id], {'account_debit': debit_account})
+            if not rule.account_credit.id:
+                rule_obj.write(cr, uid, [rule.id], {'account_credit': credit_account})
+            #Assigning Debit/Credit account on payslip lines
+            for value in result:
+                if value['salary_rule_id'] == rule.id:
+                    if rule.category_id.name == 'Deduction':
+                        if not rule.account_debit.id:
+                            value['account_id'] = debit_account
+                        else:
+                            value['account_id'] = rule.account_debit.id
+                    elif rule.category_id.name == 'Allowance':
+                        if not rule.account_credit.id:
+                            value['account_id'] = credit_account
+                        else:
+                            value['account_id'] = rule.account_credit.id
+                    else:
+                        emp_account_id = self.browse(cr, uid, payslip_id, context=context).employee_id.employee_account.id
+                        value['account_id'] = emp_account_id
+                    if rule.analytic_account_id:
+                        value['analytic_account_id'] = rule.analytic_account_id.id
+        return result
+
     def create_voucher(self, cr, uid, ids, name, voucher, sequence=5):
         slip_move = self.pool.get('hr.payslip.account.move')
         for slip in ids:
@@ -243,10 +301,8 @@
                     if line.move_id.state == 'posted':
                         move_pool.button_cancel(cr, uid [line.move_id.id], context)
                     move_pool.unlink(cr, uid, [line.move_id.id], context=context)
-
         slip_move.unlink(cr, uid, move_ids, context=context)
-        self.write(cr, uid, ids, {'state':'cancel'}, context=context)
-        return True
+        return self.write(cr, uid, ids, {'state':'cancel'}, context=context)
 
     def process_sheet(self, cr, uid, ids, context=None):
         move_pool = self.pool.get('account.move')
@@ -268,17 +324,21 @@
             partner = slip.employee_id.bank_account_id.partner_id
             partner_id = partner.id
 
+            for line in slip.line_ids:
+                if line.category_id.code == 'NET':
+                    amt = line.total
+
             fiscal_year_ids = fiscalyear_pool.search(cr, uid, [], context=context)
             if not fiscal_year_ids:
                 raise osv.except_osv(_('Warning !'), _('Please define fiscal year for perticular contract'))
             fiscal_year_objs = fiscalyear_pool.read(cr, uid, fiscal_year_ids, ['date_start','date_stop'], context=context)
             year_exist = False
             for fiscal_year in fiscal_year_objs:
-                if ((fiscal_year['date_start'] <= slip.date) and (fiscal_year['date_stop'] >= slip.date)):
+                if ((fiscal_year['date_start'] <= slip.date_from) and (fiscal_year['date_stop'] >= slip.date_to)):
                     year_exist = True
             if not year_exist:
                 raise osv.except_osv(_('Warning !'), _('Fiscal Year is not defined for slip date %s') % slip.date)
-            search_periods = period_pool.search(cr, uid, [('date_start','<=',slip.date),('date_stop','>=',slip.date)], context=context)
+            search_periods = period_pool.search(cr, uid, [('date_start','<=',slip.date_from),('date_stop','>=',slip.date_to)], context=context)
             if not search_periods:
                 raise osv.except_osv(_('Warning !'), _('Period is not defined for slip date %s') % slip.date)
             period_id = search_periods[0]
@@ -286,7 +346,7 @@
             move = {
                 'journal_id': slip.bank_journal_id.id,
                 'period_id': period_id,
-                'date': slip.date,
+                'date': slip.date_from,
                 'type':'bank_pay_voucher',
                 'ref':slip.number,
                 'narration': name
@@ -302,10 +362,10 @@
             ded_rec = {
                 'move_id': move_id,
                 'name': name,
-                'date': slip.date,
+                'date': slip.date_from,
                 'account_id': slip.employee_id.property_bank_account.id,
                 'debit': 0.0,
-                'credit': slip.total_pay,
+                'credit': amt,
                 'journal_id': slip.journal_id.id,
                 'period_id': period_id,
                 'ref': slip.number
@@ -316,9 +376,9 @@
                 'move_id': move_id,
                 'name': name,
                 'partner_id': partner_id,
-                'date': slip.date,
+                'date': slip.date_from,
                 'account_id': partner.property_account_payable.id,
-                'debit': slip.total_pay,
+                'debit': amt,
                 'credit': 0.0,
                 'journal_id': slip.journal_id.id,
                 'period_id': period_id,
@@ -326,74 +386,75 @@
             }
             line_ids += [movel_pool.create(cr, uid, cre_rec, context=context)]
 
-            other_pay = slip.other_pay
+#            other_pay = slip.other_pay
             #Process all Reambuse Entries
-            for line in slip.line_ids:
-                if line.type == 'otherpay' and line.expanse_id.invoice_id:
-                    if not line.expanse_id.invoice_id.move_id:
-                        raise osv.except_osv(_('Warning !'), _('Please Confirm all Expense Invoice appear for Reimbursement'))
-                    invids = [line.expanse_id.invoice_id.id]
-                    amount = line.total
-                    acc_id = slip.bank_journal_id.default_credit_account_id and slip.bank_journal_id.default_credit_account_id.id
-                    period_id = slip.period_id.id
-                    journal_id = slip.bank_journal_id.id
-                    name = '[%s]-%s' % (slip.number, line.name)
-                    invoice_pool.pay_and_reconcile(cr, uid, invids, amount, acc_id, period_id, journal_id, False, period_id, False, context, name)
-                    other_pay -= amount
-                    #TODO: link this account entries to the Payment Lines also Expense Entries to Account Lines
-                    l_ids = movel_pool.search(cr, uid, [('name','=',name)], context=context)
-                    line_ids += l_ids
-
-                    l_ids = movel_pool.search(cr, uid, [('invoice','=',line.expanse_id.invoice_id.id)], context=context)
-                    exp_ids += l_ids
+#            for line in slip.line_ids:
+#                if line.type == 'otherpay' and line.expanse_id.invoice_id:
+#                    if not line.expanse_id.invoice_id.move_id:
+#                        raise osv.except_osv(_('Warning !'), _('Please Confirm all Expense Invoice appear for Reimbursement'))
+#                    invids = [line.expanse_id.invoice_id.id]
+#                    amount = line.total
+#                    acc_id = slip.bank_journal_id.default_credit_account_id and slip.bank_journal_id.default_credit_account_id.id
+#                    period_id = slip.period_id.id
+#                    journal_id = slip.bank_journal_id.id
+#                    name = '[%s]-%s' % (slip.number, line.name)
+#                    invoice_pool.pay_and_reconcile(cr, uid, invids, amount, acc_id, period_id, journal_id, False, period_id, False, context, name)
+#                    other_pay -= amount
+#                    #TODO: link this account entries to the Payment Lines also Expense Entries to Account Lines
+#                    l_ids = movel_pool.search(cr, uid, [('name','=',name)], context=context)
+#                    line_ids += l_ids
+#
+#                    l_ids = movel_pool.search(cr, uid, [('invoice','=',line.expanse_id.invoice_id.id)], context=context)
+#                    exp_ids += l_ids
 
             #Process for Other payment if any
-            other_move_id = False
-            if slip.other_pay > 0:
-                narration = 'Payment of Other Payeble amounts to %s' % (slip.employee_id.name)
-                move = {
-                    'journal_id': slip.bank_journal_id.id,
-                    'period_id': period_id,
-                    'date': slip.date,
-                    'type':'bank_pay_voucher',
-                    'ref':slip.number,
-                    'narration': narration
-                }
-                other_move_id = move_pool.create(cr, uid, move, context=context)
-                self.create_voucher(cr, uid, [slip.id], narration, move_id)
-
-                name = "To %s account" % (slip.employee_id.name)
-                ded_rec = {
-                    'move_id':other_move_id,
-                    'name':name,
-                    'date':slip.date,
-                    'account_id':slip.employee_id.property_bank_account.id,
-                    'debit': 0.0,
-                    'credit': other_pay,
-                    'journal_id':slip.journal_id.id,
-                    'period_id':period_id,
-                    'ref':slip.number
-                }
-                line_ids += [movel_pool.create(cr, uid, ded_rec, context=context)]
-                name = "By %s account" % (slip.employee_id.property_bank_account.name)
-                cre_rec = {
-                    'move_id':other_move_id,
-                    'name':name,
-                    'partner_id':partner_id,
-                    'date':slip.date,
-                    'account_id':partner.property_account_payable.id,
-                    'debit': other_pay,
-                    'credit':0.0,
-                    'journal_id':slip.journal_id.id,
-                    'period_id':period_id,
-                    'ref':slip.number
-                }
-                line_ids += [movel_pool.create(cr, uid, cre_rec, context=context)]
+#            other_move_id = False
+#            if slip.other_pay > 0:
+#                narration = 'Payment of Other Payeble amounts to %s' % (slip.employee_id.name)
+#                move = {
+#                    'journal_id': slip.bank_journal_id.id,
+#                    'period_id': period_id,
+#                    'date': slip.date_from,
+#                    'type':'bank_pay_voucher',
+#                    'ref':slip.number,
+#                    'narration': narration
+#                }
+#                other_move_id = move_pool.create(cr, uid, move, context=context)
+#                self.create_voucher(cr, uid, [slip.id], narration, move_id)
+#
+#                name = "To %s account" % (slip.employee_id.name)
+#                ded_rec = {
+#                    'move_id':other_move_id,
+#                    'name':name,
+#                    'date':slip.date_from,
+#                    'account_id':slip.employee_id.property_bank_account.id,
+#                    'debit': 0.0,
+#                    'credit': other_pay,
+#                    'journal_id':slip.journal_id.id,
+#                    'period_id':period_id,
+#                    'ref':slip.number
+#                }
+#                line_ids += [movel_pool.create(cr, uid, ded_rec, context=context)]
+#                name = "By %s account" % (slip.employee_id.property_bank_account.name)
+#                cre_rec = {
+#                    'move_id':other_move_id,
+#                    'name':name,
+#                    'partner_id':partner_id,
+#                    'date':slip.date_from,
+#                    'account_id':partner.property_account_payable.id,
+#                    'debit': other_pay,
+#                    'credit':0.0,
+#                    'journal_id':slip.journal_id.id,
+#                    'period_id':period_id,
+#                    'ref':slip.number
+#                }
+#                line_ids += [movel_pool.create(cr, uid, cre_rec, context=context)]
 
             rec = {
                 'state':'done',
                 'move_payment_ids':[(6, 0, line_ids)],
-                'paid':True
+                'paid':True,
+                'account_move_ids': [(4, move_id)],
             }
             self.write(cr, uid, [slip.id], rec, context=context)
             for exp_id in exp_ids:
@@ -402,12 +463,10 @@
         return True
 
     def account_check_sheet(self, cr, uid, ids, context=None):
-        self.write(cr, uid, ids, {'state':'accont_check'}, context=context)
-        return True
+        return self.write(cr, uid, ids, {'state':'accont_check'}, context=context)
 
     def hr_check_sheet(self, cr, uid, ids, context=None):
-        self.write(cr, uid, ids, {'state':'hr_check'}, context=context)
-        return True
+        return self.write(cr, uid, ids, {'state':'hr_check'}, context=context)
 
     def verify_sheet(self, cr, uid, ids, context=None):
         move_pool = self.pool.get('account.move')
@@ -419,6 +478,9 @@
         payslip_pool = self.pool.get('hr.payslip.line')
 
         for slip in self.browse(cr, uid, ids, context=context):
+            for line in slip.line_ids:
+                if line.category_id.code == 'BASIC':
+                    basic_amt = line.total
             if not slip.journal_id:
                 # Call super method to verify sheet if journal_id is not specified.
                 super(hr_payslip, self).verify_sheet(cr, uid, [slip.id], context=context)
@@ -426,6 +488,7 @@
             total_deduct = 0.0
 
             line_ids = []
+            move_ids = []
             partner = False
             partner_id = False
 
@@ -449,11 +512,11 @@
                 fiscal_year_objs = fiscalyear_pool.read(cr, uid, fiscal_year_ids, ['date_start','date_stop'], context=context)
                 year_exist = False
                 for fiscal_year in fiscal_year_objs:
-                    if ((fiscal_year['date_start'] <= slip.date) and (fiscal_year['date_stop'] >= slip.date)):
+                    if ((fiscal_year['date_start'] <= slip.date_from) and (fiscal_year['date_stop'] >= slip.date_to)):
                         year_exist = True
                 if not year_exist:
                     raise osv.except_osv(_('Warning !'), _('Fiscal Year is not defined for slip date %s') % slip.date)
-                search_periods = period_pool.search(cr,uid,[('date_start','<=',slip.date),('date_stop','>=',slip.date)], context=context)
+                search_periods = period_pool.search(cr,uid,[('date_start','=',slip.date_from),('date_stop','=',slip.date_to)], context=context)
                 if not search_periods:
                     raise osv.except_osv(_('Warning !'), _('Period is not defined for slip date %s') % slip.date)
                 period_id = search_periods[0]
@@ -461,11 +524,12 @@
             move = {
                 'journal_id': slip.journal_id.id,
                 'period_id': period_id,
-                'date': slip.date,
+                'date': slip.date_from,
                 'ref':slip.number,
                 'narration': slip.name
             }
             move_id = move_pool.create(cr, uid, move, context=context)
+            move_ids += [move_id]
             self.create_voucher(cr, uid, [slip.id], slip.name, move_id)
 
             if not slip.employee_id.salary_account.id:
@@ -474,17 +538,16 @@
             line = {
                 'move_id':move_id,
                 'name': "By Basic Salary / " + slip.employee_id.name,
-                'date': slip.date,
+                'date': slip.date_from,
                 'account_id': slip.employee_id.salary_account.id,
-                'debit': slip.basic,
+                'debit': basic_amt,
                 'credit': 0.0,
-                'quantity':slip.working_days,
+#                'quantity':slip.working_days,
                 'journal_id': slip.journal_id.id,
                 'period_id': period_id,
                 '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
@@ -499,28 +562,30 @@
                 'move_id':move_id,
                 'name': "To Basic Payble Salary / " + slip.employee_id.name,
                 'partner_id': partner_id,
-                'date': slip.date,
+                'date': slip.date_from,
                 'account_id': slip.employee_id.employee_account.id,
                 'debit': 0.0,
-                'quantity':slip.working_days,
-                'credit': slip.basic,
+#                'quantity':slip.working_days,
+                'credit': basic_amt,
                 'journal_id': slip.journal_id.id,
                 'period_id': period_id,
                 'ref':slip.number
             }
             line_ids += [movel_pool.create(cr, uid, line, context=context)]
-
+            codes = ['NET', 'GROSS', 'BASIC']
             for line in slip.line_ids:
+                if line.code in codes:
+                    continue
                 name = "[%s] - %s / %s" % (line.code, line.name, slip.employee_id.name)
                 amount = line.total
 
-                if line.type == 'leaves':
-                    continue
+#                if line.type == 'leaves':
+#                    continue
 
                 rec = {
                     'move_id': move_id,
                     'name': name,
-                    'date': slip.date,
+                    'date': slip.date_from,
                     'account_id': line.account_id.id,
                     'debit': 0.0,
                     'credit': 0.0,
@@ -534,10 +599,11 @@
                 #Setting Analysis Account for Salary Slip Lines
                 if line.analytic_account_id:
                     rec['analytic_account_id'] = line.analytic_account_id.id
-                else:
-                    rec['analytic_account_id'] = slip.deg_id.account_id.id
+#                else:
+#                    rec['analytic_account_id'] = slip.deg_id.account_id.id
 
-                if line.type == 'allowance' or line.type == 'otherpay':
+#                if line.type == 'allowance' or line.type == 'otherpay':
+                if line.category_id.code == 'ALW' :
                     rec['debit'] = amount
                     if not partner.property_account_payable:
                         raise osv.except_osv(_('Integrity Error !'), _('Please Configure Partners Payable Account!!'))
@@ -545,7 +611,7 @@
                         'move_id': move_id,
                         'name': name,
                         'partner_id': partner_id,
-                        'date': slip.date,
+                        'date': slip.date_from,
                         'account_id': partner.property_account_payable.id,
                         'debit': 0.0,
                         'quantity': 1,
@@ -555,16 +621,17 @@
                         'ref': slip.number
                     }
                     line_ids += [movel_pool.create(cr, uid, ded_rec, context=context)]
-                elif line.type == 'deduction' or line.type == 'otherdeduct':
+                elif line.category_id.code  == 'DED':
                     if not partner.property_account_receivable:
                         raise osv.except_osv(_('Integrity Error !'), _('Please Configure Partners Receivable Account!!'))
+                    amount =  -(amount)
                     rec['credit'] = amount
                     total_deduct += amount
                     ded_rec = {
                         'move_id': move_id,
                         'name': name,
                         'partner_id': partner_id,
-                        'date': slip.date,
+                        'date': slip.date_from,
                         'quantity': 1,
                         'account_id': partner.property_account_receivable.id,
                         'debit': amount,
@@ -574,23 +641,21 @@
                         'ref': slip.number
                     }
                     line_ids += [movel_pool.create(cr, uid, ded_rec, context=context)]
-
                 line_ids += [movel_pool.create(cr, uid, rec, context=context)]
-
                 # if self._debug:
                 #    for contrib in line.category_id.contribute_ids:
                 #       _log.debug("%s %s %s %s %s",  contrib.name, contrub.code, contrub.amount_type, contrib.contribute_per, line.total)
-
             adj_move_id = False
             if total_deduct > 0:
                 move = {
                     'journal_id': slip.journal_id.id,
                     'period_id': period_id,
-                    'date': slip.date,
+                    'date': slip.date_from,
                     'ref':slip.number,
                     'narration': 'Adjustment: %s' % (slip.name)
                 }
                 adj_move_id = move_pool.create(cr, uid, move, context=context)
+                move_ids += [adj_move_id]
                 name = "Adjustment Entry - %s" % (slip.employee_id.name)
                 self.create_voucher(cr, uid, [slip.id], name, adj_move_id)
 
@@ -598,7 +663,7 @@
                     'move_id': adj_move_id,
                     'name': name,
                     'partner_id': partner_id,
-                    'date': slip.date,
+                    'date': slip.date_from,
                     'account_id': partner.property_account_receivable.id,
                     'debit': 0.0,
                     'quantity': 1,
@@ -612,7 +677,7 @@
                     'move_id': adj_move_id,
                     'name': name,
                     'partner_id': partner_id,
-                    'date': slip.date,
+                    'date': slip.date_from,
                     'account_id': partner.property_account_payable.id,
                     'debit': total_deduct,
                     'quantity': 1,
@@ -626,29 +691,28 @@
             rec = {
                 'state':'confirm',
                 'move_line_ids':[(6, 0,line_ids)],
+                'account_move_ids':[(6, 0, move_ids)]
             }
             if not slip.period_id:
                 rec['period_id'] = period_id
 
-            dates = prev_bounds(slip.date)
-            exp_ids = exp_pool.search(cr, uid, [('date_valid','>=',dates[0]), ('date_valid','<=',dates[1]), ('state','=','invoiced')], context=context)
-            if exp_ids:
-                acc = property_pool.get(cr, uid, 'property_account_expense_categ', 'product.category')
-                for exp in exp_pool.browse(cr, uid, exp_ids, context=context):
-                    exp_res = {
-                        'name':exp.name,
-                        'amount_type':'fix',
-                        'type':'otherpay',
-                        'category_id':exp.category_id.id,
-                        'amount':exp.amount,
-                        'slip_id':slip.id,
-                        'expanse_id':exp.id,
-                        'account_id':acc
-                    }
-                    payslip_pool.create(cr, uid, exp_res, context=context)
-
+#            dates = prev_bounds(slip.date)
+            exp_ids = exp_pool.search(cr, uid, [('date_valid','>=',slip.date_from), ('date_valid','<=',slip.date_to), ('state','=','invoiced')], context=context)
+#            if exp_ids:
+#                acc = property_pool.get(cr, uid, 'property_account_expense_categ', 'product.category')
+#                for exp in exp_pool.browse(cr, uid, exp_ids, context=context):
+#                    exp_res = {
+#                        'name':exp.name,
+#                        'amount_type':'fix',
+#                        'type':'otherpay',
+#                        'category_id':exp.category_id.id,
+#                        'amount':exp.amount,
+#                        'slip_id':slip.id,
+#                        'expanse_id':exp.id,
+#                        'account_id':acc
+#                    }
+#                    payslip_pool.create(cr, uid, exp_res, context=context)
             self.write(cr, uid, [slip.id], rec, context=context)
-
         return True
 
 hr_payslip()
@@ -661,6 +725,17 @@
     }
 hr_payslip_line()
 
+class hr_salary_rule(osv.osv):
+    _inherit = 'hr.salary.rule'
+    _columns = {
+#        'account_id': fields.many2one('account.account', 'General Account'),
+        'analytic_account_id':fields.many2one('account.analytic.account', 'Analytic Account'),
+        'account_tax_id':fields.many2one('account.tax.code', 'Tax Code'),
+        'account_debit': fields.many2one('account.account', 'Debit Account'),
+        'account_credit': fields.many2one('account.account', 'Credit Account'),
+    }
+hr_salary_rule()
+
 class account_move_link_slip(osv.osv):
     '''
     Account Move Link to Pay Slip
@@ -675,4 +750,15 @@
     }
 account_move_link_slip()
 
+class hr_contract(osv.osv):
+
+    _inherit = 'hr.contract'
+    _description = 'Employee Contract'
+    _columns = {
+        'analytic_account_id':fields.many2one('account.analytic.account', 'Analytic Account'),
+        'journal_id': fields.many2one('account.journal', 'Journal'),
+    }
+hr_contract()
+
+
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== renamed file 'hr_payroll_account/hr_payroll_demo.xml' => 'hr_payroll_account/hr_payroll_account_demo.xml'
--- hr_payroll_account/hr_payroll_demo.xml	2011-01-14 00:11:01 +0000
+++ hr_payroll_account/hr_payroll_account_demo.xml	2011-05-12 09:30:57 +0000
@@ -2,31 +2,55 @@
 <openerp>
     <data>
 
-        <record id="hr_payroll.hr_payslip_line_houserantallowance1" model="hr.payslip.line">
-            <field name="account_id" ref="account.a_salary_expense"/>
-        </record>
-
-        <record id="hr_payroll.hr_payslip_line_convanceallowance1" model="hr.payslip.line">
-            <field name="account_id" ref="account.a_salary_expense"/>
-        </record>
-
-        <record id="hr_payroll.hr_payslip_line_professionaltax1" model="hr.payslip.line">
-            <field name="account_id" ref="account.a_salary_expense"/>
-        </record>
-
-        <record id="hr_payroll.hr_payslip_line_providentfund1" model="hr.payslip.line">
-            <field name="account_id" ref="account.a_salary_expense"/>
+        <record id="hr_payroll.hr_payslip_line_houserantallowance1" model="hr.salary.rule">
+            <field name="account_debit" ref="account.a_salary_expense"/>
+        </record>
+
+        <record id="hr_payroll.hr_payslip_line_convanceallowance1" model="hr.salary.rule">
+            <field name="account_debit" ref="account.a_salary_expense"/>
+        </record>
+
+        <record id="hr_payroll.hr_payslip_line_professionaltax1" model="hr.salary.rule">
+            <field name="account_debit" ref="account.a_salary_expense"/>
+        </record>
+
+        <record id="hr_payroll.hr_payslip_line_providentfund1" model="hr.salary.rule">
+            <field name="account_debit" ref="account.a_salary_expense"/>
+        </record>
+        
+         <record id="hr_payroll.hr_salary_rule_meal_voucher" model="hr.salary.rule">
+            <field name="account_debit" ref="account.a_salary_expense"/>
+        </record>
+        
+        <record id="hr_payroll.hr_salary_rule_ca_paolino" model="hr.salary.rule">
+            <field name="account_debit" ref="account.a_salary_expense"/>
+        </record>
+        
+        <record id="hr_payroll.hr_rule_basic" model="hr.salary.rule">
+            <field name="account_debit" ref="account.a_salary_expense"/>
+        </record>
+        
+        <record id="hr_payroll.hr_rule_taxable" model="hr.salary.rule">
+            <field name="account_debit" ref="account.a_salary_expense"/>
+        </record>
+        
+        <record id="hr_payroll.hr_rule_net" model="hr.salary.rule">
+            <field name="account_debit" ref="account.a_salary_expense"/>
+        </record>
+        
+        <record id="hr_payroll.hr_payslip_line_houserantallowance1" model="hr.salary.rule">
+            <field name="account_debit" ref="account.a_salary_expense"/>
         </record>
 
         <!-- Payslip -->
-        <record id="hr_payroll.hr_payslip_salaryslipofbonamyforjune0" model="hr.payslip">
+       <!-- <record id="hr_payroll.hr_payslip_salaryslipofbonamyforjune0" model="hr.payslip">
             <field name="journal_id" ref="account.expenses_journal"/>
             <field name="bank_journal_id" ref="account.bank_journal"/>
-        </record>
+        </record>-->
 
         <!-- Assigned Default Account in Different Demo Employees -->
 
-        <!--record id="hr.employee" model="hr.employee">
+       <!-- <record id="hr.employee" model="hr.employee">
             <field name="property_bank_account" ref="account.bnk"/>
             <field name="salary_account" ref="account.a_salary_expense"/>
             <field name="employee_account" ref="account.a_expense"/>
@@ -54,7 +78,7 @@
             <field name="property_bank_account" ref="account.bnk"/>
             <field name="salary_account" ref="account.a_salary_expense"/>
             <field name="employee_account" ref="account.a_expense"/>
-        </record-->
+        </record>-->
 
         <record id="bnk" model="account.account">
             <field name="code">X110041</field>
@@ -72,12 +96,13 @@
             <field name="user_type" ref="account.account_type_expense"/>
         </record>
 
-        <record id="a_expense" model="account.account">
-            <field name="code">X21102</field>
-            <field name="name">Expenses</field>
-            <field ref="account.ovr" name="parent_id"/>
-            <field name="type">other</field>
-            <field name="user_type" ref="account.account_type_expense"/>
+        <record id="a_creditors" model="account.account">
+            <field name="code">X11111</field>
+            <field name="name">Employee Payable Account</field>
+            <field ref="account.cli" name="parent_id"/>
+            <field name="type">payable</field>
+            <field eval="True" name="reconcile"/>
+            <field name="user_type" ref="account.account_type_payable"/>
         </record>
 
         <!-- Properties -->
@@ -98,7 +123,7 @@
         <record forcecreate="True" id="employee_account" model="ir.property">
             <field name="name">employee_account</field>
             <field name="fields_id" search="[('model','=','hr.employee'),('name','=','employee_account')]"/>
-            <field eval="'account.account,'+str(a_expense)" name="value"/>
+            <field eval="'account.account,'+str(a_creditors)" name="value"/>
             <field name="company_id" ref="base.main_company"/>
         </record>
 

=== modified file 'hr_payroll_account/hr_payroll_account_view.xml'
--- hr_payroll_account/hr_payroll_account_view.xml	2011-03-10 13:18:08 +0000
+++ hr_payroll_account/hr_payroll_account_view.xml	2011-05-12 09:30:57 +0000
@@ -2,29 +2,13 @@
 <openerp>
     <data>
 
-
-        <record model="ir.ui.view" id="view_holiday_status_inherit_form1">
-            <field name="name">hr.holidays.status.inherit1</field>
-            <field name="model">hr.holidays.status</field>
-            <field name="inherit_id" ref="hr_payroll.view_holiday_status_form1"/>
-            <field name="type">form</field>
-            <field name="arch" type="xml">
-                <field name="code" position="after">
-                   <field name="analytic_account_id"/>
-				   <newline/>
-                   <field name="account_id"/>
-				   <newline/>
-                </field>
-            </field>
-        </record>
-
         <record model="ir.ui.view" id="view_hr_payslip_line_inherit_tree">
             <field name="name">hr.payslip.line.inherit.tree</field>
             <field name="model">hr.payslip.line</field>
             <field name="inherit_id" ref="hr_payroll.view_hr_payslip_line_tree"/>
             <field name="type">tree</field>
             <field name="arch" type="xml">
-                <field name="amount" position="after">
+                <field name="category_id" position="after">
                    <field name="analytic_account_id"/>
                    <field name="account_id" required="1"/>
                 </field>
@@ -44,7 +28,7 @@
             </field>
         </record>
 
-        <record model="ir.ui.view" id="view_hr_employee_grade_inherit_form">
+       <!-- <record model="ir.ui.view" id="view_hr_employee_grade_inherit_form">
             <field name="name">hr.employee.grade.inherit.form</field>
             <field name="model">hr.payroll.structure</field>
             <field name="inherit_id" ref="hr_payroll.view_hr_employee_grade_form"/>
@@ -54,7 +38,7 @@
                    <field name="account_id" required="1"/>
                 </xpath>
             </field>
-        </record>
+        </record>-->
 
         <record model="ir.ui.view" id="view_hr_payslip_inherit_form">
             <field name="name">hr.payslip.inherit.form</field>
@@ -62,9 +46,10 @@
             <field name="inherit_id" ref="hr_payroll.view_hr_payslip_form"/>
             <field name="type">form</field>
             <field name="arch" type="xml">
-                <field name="date" position="before">
+                <field name="date_to" position="after">
                     <field name="journal_id" required="1"/>
                     <field name="bank_journal_id" domain="[('type','=','cash')]" required="1"/>
+                    <field name="period_id" />
                 </field>
             </field>
         </record>
@@ -80,58 +65,20 @@
                    <field name="account_id" required="1"/>
                    <field name="analytic_account_id"/>
                 </xpath>
-                <xpath expr="/form/notebook/page[@string='Salary Computation']/field[@name='line_ids']/form/group/field[@name='company_contrib']" position="before">
+                <xpath expr="/form/notebook/page[@string='Salary Computation']/field[@name='line_ids']/form/group/field[@name='salary_rule_id']" position="after">
                    <field name="account_id" required="1"/>
                    <field name="analytic_account_id"/>
                 </xpath>
             </field>
         </record>
 
-        <record model="ir.ui.view" id="view_hr_bank_advice_inherit_form">
-            <field name="name">hr.payroll.advice.inherit.form</field>
-            <field name="model">hr.payroll.advice</field>
-            <field name="inherit_id" ref="hr_payroll.view_hr_bank_advice_form"/>
-            <field name="type">form</field>
-            <field name="arch" type="xml">
-                <field name="name" position="after">
-                    <field name="account_id" required="1"/>
-                </field>
-            </field>
-        </record>
-
-        <record model="ir.ui.view" id="view_hr_payroll_register_inherit_tree">
-            <field name="name">hr.payroll.register.inherit.tree</field>
-            <field name="model">hr.payroll.register</field>
-            <field name="inherit_id" ref="hr_payroll.view_hr_payroll_register_tree"/>
-            <field name="type">tree</field>
-            <field name="arch" type="xml">
-                <field name="state" position="before">
-                    <field name="journal_id" required="1"/>
-                    <field name="bank_journal_id" required="1"/>
-                </field>
-            </field>
-        </record>
-
-        <record model="ir.ui.view" id="view_hr_payroll_register_inherit_form">
-            <field name="name">hr.payroll.register.inherit.form</field>
-            <field name="model">hr.payroll.register</field>
-            <field name="inherit_id" ref="hr_payroll.view_hr_payroll_register_form"/>
-            <field name="type">form</field>
-            <field name="arch" type="xml">
-                <field name="number" position="after">
-                    <field name="journal_id" required="1"/>
-                    <field name="bank_journal_id" required="1"/>
-                </field>
-            </field>
-        </record>
-
         <record model="ir.ui.view" id="hr_contibution_register_inherit_tree">
-            <field name="name">hr.contibution.register.inherit.tree</field>
-            <field name="model">hr.contibution.register</field>
-            <field name="inherit_id" ref="hr_payroll.hr_contibution_register_tree"/>
+            <field name="name">hr.contribution.register.inherit.tree</field>
+            <field name="model">hr.contribution.register</field>
+            <field name="inherit_id" ref="hr_payroll.hr_contribution_register_tree"/>
             <field name="type">tree</field>
             <field name="arch" type="xml">
-                <field name="monthly_total_by_comp" position="after">
+                <field name="name" position="after">
                     <field name="yearly_total_by_emp"/>
                     <field name="yearly_total_by_comp"/>
                 </field>
@@ -139,45 +86,35 @@
         </record>
 
         <record model="ir.ui.view" id="hr_contibution_register_inherit_form">
-            <field name="name">hr.contibution.register.inherit.form</field>
-            <field name="model">hr.contibution.register</field>
-            <field name="inherit_id" ref="hr_payroll.hr_contibution_register_form"/>
+            <field name="name">hr.contribution.register.inherit.form</field>
+            <field name="model">hr.contribution.register</field>
+            <field name="inherit_id" ref="hr_payroll.hr_contribution_register_form"/>
             <field name="type">form</field>
             <field name="arch" type="xml">
-                <field name="name" position="after">
-                    <field name="account_id" required="1"/>
-                    <field name="analytic_account_id"/>
-                </field>
+             <xpath expr="/form/notebook" position="before">
+                <newline/>
+                <field name="account_id" />
+                <field name="analytic_account_id"/>
+             </xpath>
             </field>
         </record>
 
-        <record model="ir.ui.view" id="hr_contibution_register_inherit1_form">
-            <field name="name">hr.contibution.register.inherit1.form</field>
-            <field name="model">hr.contibution.register</field>
-            <field name="inherit_id" ref="hr_payroll.hr_contibution_register_form"/>
+      <!--  <record model="ir.ui.view" id="hr_contibution_register_inherit1_form">
+            <field name="name">hr.contribution.register.inherit1.form</field>
+            <field name="model">hr.contribution.register</field>
+            <field name="inherit_id" ref="hr_payroll.hr_contribution_register_form"/>
             <field name="type">form</field>
             <field name="arch" type="xml">
-                <group name="Month" position="after">
+              <xpath expr="/form/notebook" position="before">
                     <group col="2" colspan="2">
+                    <newline/>
                         <separator colspan="4" string="Year"/>
                         <field name="yearly_total_by_emp"/>
                         <field name="yearly_total_by_comp"/>
                     </group>
-                </group>
-            </field>
-        </record>
-
-        <record model="ir.ui.view" id="hr_contibution_register_line_inherit_form">
-            <field name="name">hr.contibution.register.line.form.inherit</field>
-            <field name="model">hr.contibution.register.line</field>
-            <field name="inherit_id" ref="hr_payroll.hr_contibution_register_line_form"/>
-            <field name="type">form</field>
-            <field name="arch" type="xml">
-                <field name="employee_id" position="after">
-                   <field name="period_id"/>
-                </field>
-            </field>
-        </record>
+               </xpath>
+            </field>
+        </record>-->
 
         <record id="view_hr_payslip_form_inherit" model="ir.ui.view">
 		    <field name="name">hr.payslip.form</field>
@@ -185,7 +122,7 @@
 		    <field name="type">form</field>
 		    <field name="inherit_id" ref="hr_payroll.view_hr_payslip_form"/>
 		    <field name="arch" type="xml">
-		      <page string="Other Informations" position="replace">
+		      <xpath expr="/form/notebook/page[@string='Other Information']" position="replace">
 	            <page string="Accounting Details">
 	                <group col="4" colspan="3">
 	                    <separator colspan="4" string="Accounting Informations"/>
@@ -203,37 +140,28 @@
 	                    </field>
 	                </group>
 	                <group col="2" colspan="1">
-	                    <separator colspan="2" string="Other Informations"/>
-	                    <field name="paid" readonly="1"/>
-	                    <field name="company_id"/>
-	                    <field name="register_id"/>
-	                    <field name="deg_id"/>
-	                    <field name="contract_id" domain="[('employee_id','=',employee_id)]"/>
+	                    <separator colspan="4" string="Other Information"/>
+                        <group col="5" colspan="2">
+                            <field name="company_id" groups="base.group_multi_company" widget="selection"/>
+                            <newline/>
+                            <field name="paid" readonly="1"/>
+                        </group>
 	                </group>
-	                <separator colspan="4" string="Description"/>
-	                <field name="note" colspan="4" nolabel="1"/>
+	               <separator colspan="4" string="Notes"/>
+                   <field name="note" colspan="4" nolabel="1"/>
 	            </page>
-	           </page>
-		    </field>
-		</record>
-
-		<record id="view_hr_payslip_form_inherit1" model="ir.ui.view">
-		    <field name="name">hr.payslip.form</field>
-		    <field name="model">hr.payslip</field>
-		    <field name="type">form</field>
-		    <field name="inherit_id" ref="view_hr_payslip_form_inherit"/>
-		    <field name="arch" type="xml">
-		        <notebook position="inside">
-		            <page string="Account Lines">
-		                <field name="move_line_ids" colspan="4" nolabel="1"/>
-		            </page>
-		            <page string="Payment Lines">
-		                <field name="move_payment_ids" colspan="4" nolabel="1"/>
-		            </page>
-		        </notebook>
-		    </field>
-		</record>
-
+	      		<page string="Account Lines">
+		       		<field name="move_line_ids" colspan="4" nolabel="1"/>
+		        </page>
+		        <page string="Payment Lines">
+	        		<field name="move_payment_ids" colspan="4" nolabel="1"/>
+	        	</page>
+		        <page string="Accounting Entries">
+                	<field name="account_move_ids" colspan="4" nolabel="1"/>
+                </page>
+              </xpath>
+	        </field>
+		</record>
 
         <!-- Adding Account Properties to the Employee form -->
 
@@ -251,5 +179,39 @@
             </field>
         </record>
 
+    <!-- Adding Account fields to the Salary Rules -->
+
+        <record id="hr_salary_rule_form_inherit" model="ir.ui.view">
+            <field name="name">hr.salary.rule.form.inherit</field>
+            <field name="model">hr.salary.rule</field>
+            <field name="inherit_id" ref="hr_payroll.hr_salary_rule_form"/>
+            <field name="arch" type="xml">
+              <xpath expr="/form/notebook/page[@string='Child Rules']" position="after">
+                    <page string="Accounting">
+	                    <field name="account_debit" />
+	                    <field name="account_credit"/>
+	                    <field name="analytic_account_id"/>
+	                    <field name="account_tax_id"/>
+                    </page>
+                </xpath>
+            </field>
+        </record>
+
+    <!-- Contract View -->
+
+        <record id="hr_contract_form_inherit" model="ir.ui.view">
+            <field name="name">hr.contract.view.form.inherit</field>
+            <field name="model">hr.contract</field>
+            <field name="type">form</field>
+            <field name="inherit_id" ref="hr_contract.hr_contract_view_form"/>
+            <field name="arch" type="xml">
+	            <xpath expr="/form/notebook/page/group/field[@name='advantages']" position="after">
+	               <separator colspan="4" string="Accounting"/>
+	                <field name="analytic_account_id"/>
+	                <field name="journal_id"/>
+	            </xpath>
+            </field>
+        </record>
+
     </data>
 </openerp>


Follow ups