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

Proposed by Meera Trambadia (OpenERP)
Status: Rejected
Rejected by: qdp (OpenERP)
Proposed branch: lp:~openerp-dev/openobject-addons/trunk-payroll-account-mtr
Merge into: lp:~openerp-dev/openobject-addons/trunk-payroll
Diff against target: 1269 lines (+448/-373)
5 files modified
hr_payroll/hr_payroll.py (+3/-1)
hr_payroll_account/__openerp__.py (+1/-1)
hr_payroll_account/hr_payroll_account.py (+312/-226)
hr_payroll_account/hr_payroll_account_demo.xml (+50/-25)
hr_payroll_account/hr_payroll_account_view.xml (+82/-120)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/trunk-payroll-account-mtr
Reviewer Review Type Date Requested Status
Mustufa Rangwala (Open ERP) Approve
qdp (OpenERP) Pending
Review via email: mp+60745@code.launchpad.net

This proposal supersedes a proposal from 2011-05-12.

Description of the change

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

To post a comment you must log in.
Revision history for this message
Mustufa Rangwala (Open ERP) (mra-tinyerp) wrote : Posted in a previous version of this proposal

I can not create new payslip.

File "/home/mra/rdtools/server/trunk/openerp/osv/orm.py", line 1453, in raise_view_error
    'model': self._name, })
AttributeError: View definition error for inherited view 'hr_payroll_account.view_hr_payslip_form_inherit_1' on 'hr.payslip' model: Element '<xpath expr="/form/notebook/page[@string='Salary Computation']/field[@name='line_ids']/form/group/field[@name='company_contrib']">' not found in parent view 'hr_payroll.view_hr_payslip_form'

review: Needs Fixing
Revision history for this message
Mustufa Rangwala (Open ERP) (mra-tinyerp) wrote : Posted in a previous version of this proposal

fix this:

1. if line.name == 'Net' or line.name == 'Gross' or line.name == 'Basic': => use line.code instead of line.name
2. line.category_id.name => use line.category_id.code every where.

thanks,
mra

Revision history for this message
Meera Trambadia (OpenERP) (mtr-openerp) wrote : Posted in a previous version of this proposal

Hello sir,

I have made changes as described above.

Thanks
mtr

Revision history for this message
Mustufa Rangwala (Open ERP) (mra-tinyerp) wrote : Posted in a previous version of this proposal

Conflicts detected in your merge proposal.

review: Needs Fixing
Revision history for this message
Mustufa Rangwala (Open ERP) (mra-tinyerp) wrote : Posted in a previous version of this proposal

Whatever done in the merge seems ok.
I approve the branch an i let the Quentin (qdp) to review it completely.

thanks,
mra

review: Approve
Revision history for this message
Mustufa Rangwala (Open ERP) (mra-tinyerp) :
review: Approve
Revision history for this message
qdp (OpenERP) (qdp) wrote :

i merged another branch that i made but which is based on this one. so i'm rejecting this merge proposal to clear my pending merge to do list

Thanks

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== 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 @@
370370
371 def compute_sheet(self, cr, uid, ids, context=None):371 def compute_sheet(self, cr, uid, ids, context=None):
372 slip_line_pool = self.pool.get('hr.payslip.line')372 slip_line_pool = self.pool.get('hr.payslip.line')
373 sequence_obj = self.pool.get('ir.sequence')
373 for payslip in self.browse(cr, uid, ids, context=context):374 for payslip in self.browse(cr, uid, ids, context=context):
375 number = sequence_obj.get(cr, uid, 'salary.slip')
374 #delete old payslip lines376 #delete old payslip lines
375 old_slipline_ids = slip_line_pool.search(cr, uid, [('slip_id', '=', payslip.id)], context=context)377 old_slipline_ids = slip_line_pool.search(cr, uid, [('slip_id', '=', payslip.id)], context=context)
376# old_slipline_ids378# old_slipline_ids
@@ -383,7 +385,7 @@
383 #if we don't give the contract, then the rules to apply should be for all current contracts of the employee385 #if we don't give the contract, then the rules to apply should be for all current contracts of the employee
384 contract_ids = self.get_contract(cr, uid, payslip.employee_id, payslip.date_from, payslip.date_to, context=context)386 contract_ids = self.get_contract(cr, uid, payslip.employee_id, payslip.date_from, payslip.date_to, context=context)
385 lines = [(0,0,line) for line in self.pool.get('hr.payslip').get_payslip_lines(cr, uid, contract_ids, payslip.id, context=context)]387 lines = [(0,0,line) for line in self.pool.get('hr.payslip').get_payslip_lines(cr, uid, contract_ids, payslip.id, context=context)]
386 self.write(cr, uid, [payslip.id], {'line_ids': lines}, context=context)388 self.write(cr, uid, [payslip.id], {'line_ids': lines, 'number': number,}, context=context)
387 return True389 return True
388390
389 def get_worked_day_lines(self, cr, uid, contract_ids, date_from, date_to, context=None):391 def get_worked_day_lines(self, cr, uid, contract_ids, date_from, date_to, context=None):
390392
=== 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 @@
46 "hr_payroll_account_view.xml",46 "hr_payroll_account_view.xml",
47 ],47 ],
48 'demo_xml': [48 'demo_xml': [
49 'hr_payroll_demo.xml'49 'hr_payroll_account_demo.xml'
50 ],50 ],
51 'installable': True,51 'installable': True,
52 'active': False,52 'active': False,
5353
=== 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 @@
27from tools import config27from tools import config
28from tools.translate import _28from tools.translate import _
2929
30def prev_bounds(cdate=False):30#def prev_bounds(cdate=False):
31 when = date.fromtimestamp(time.mktime(time.strptime(cdate,"%Y-%m-%d")))31# when = date.fromtimestamp(time.mktime(time.strptime(cdate,"%Y-%m-%d")))
32 this_first = date(when.year, when.month, 1)32# this_first = date(when.year, when.month, 1)
33 month = when.month + 133# month = when.month + 1
34 year = when.year34# year = when.year
35 if month > 12:35# if month > 12:
36 month = 136# month = 1
37 year += 137# year += 1
38 next_month = date(year, month, 1)38# next_month = date(year, month, 1)
39 prev_end = next_month - timedelta(days=1)39# prev_end = next_month - timedelta(days=1)
40 return this_first, prev_end40# return this_first, prev_end
4141
42class hr_payroll_structure(osv.osv):42class hr_payroll_structure(osv.osv):
43 _inherit = 'hr.payroll.structure'43 _inherit = 'hr.payroll.structure'
@@ -80,7 +80,7 @@
80 relation='account.account',80 relation='account.account',
81 string="Employee Account",81 string="Employee Account",
82 method=True,82 method=True,
83 domain="[('type', '=', 'other')]",83 domain="[('type', '=', 'payable')]",
84 view_load=True,84 view_load=True,
85 help="Employee Payable Account"),85 help="Employee Payable Account"),
86 'analytic_account':fields.property(86 'analytic_account':fields.property(
@@ -94,90 +94,90 @@
94 }94 }
95hr_employee()95hr_employee()
9696
97class payroll_register(osv.osv):97#class payroll_register(osv.osv):
98 _inherit = 'hr.payroll.register'98# _inherit = 'hr.payroll.register'
99 _description = 'Payroll Register'99# _description = 'Payroll Register'
100100#
101 _columns = {101# _columns = {
102 'journal_id': fields.many2one('account.journal', 'Expense Journal'),102# 'journal_id': fields.many2one('account.journal', 'Expense Journal'),
103 'bank_journal_id': fields.many2one('account.journal', 'Bank Journal'),103# 'bank_journal_id': fields.many2one('account.journal', 'Bank Journal'),
104 'period_id': fields.many2one('account.period', 'Force Period', domain=[('state','<>','done')], help="Keep empty to use the period of the validation(Payslip) date."),104# 'period_id': fields.many2one('account.period', 'Force Period', domain=[('state','<>','done')], help="Keep empty to use the period of the validation(Payslip) date."),
105 }105# }
106106#
107 def compute_sheet(self, cr, uid, ids, context=None):107# def compute_sheet(self, cr, uid, ids, context=None):
108 emp_pool = self.pool.get('hr.employee')108# emp_pool = self.pool.get('hr.employee')
109 slip_pool = self.pool.get('hr.payslip')109# slip_pool = self.pool.get('hr.payslip')
110 func_pool = self.pool.get('hr.payroll.structure')110# func_pool = self.pool.get('hr.payroll.structure')
111 slip_line_pool = self.pool.get('hr.payslip.line')111# slip_line_pool = self.pool.get('hr.payslip.line')
112 wf_service = netsvc.LocalService("workflow")112# wf_service = netsvc.LocalService("workflow")
113 vals = self.browse(cr, uid, ids, context=context)[0]113# vals = self.browse(cr, uid, ids, context=context)[0]
114 emp_ids = emp_pool.search(cr, uid, [])114# emp_ids = emp_pool.search(cr, uid, [])
115115#
116 for emp in emp_pool.browse(cr, uid, emp_ids, context=context):116# for emp in emp_pool.browse(cr, uid, emp_ids, context=context):
117 old_slips = slip_pool.search(cr, uid, [('employee_id','=', emp.id), ('date','=',vals.date)])117# old_slips = slip_pool.search(cr, uid, [('employee_id','=', emp.id), ('date','=',vals.date)])
118 if old_slips:118# if old_slips:
119 slip_pool.write(cr, uid, old_slips, {'register_id':ids[0]})119# slip_pool.write(cr, uid, old_slips, {'register_id':ids[0]})
120 for sid in old_slips:120# for sid in old_slips:
121 wf_service.trg_validate(uid, 'hr.payslip', sid, 'compute_sheet', cr)121# wf_service.trg_validate(uid, 'hr.payslip', sid, 'compute_sheet', cr)
122 else:122# else:
123 res = {123# res = {
124 'employee_id':emp.id,124# 'employee_id':emp.id,
125 'basic':0.0,125# 'basic':0.0,
126 'register_id':ids[0],126# 'register_id':ids[0],
127 'name':vals.name,127# 'name':vals.name,
128 'date':vals.date,128# 'date':vals.date,
129 'journal_id':vals.journal_id.id,129# 'journal_id':vals.journal_id.id,
130 'bank_journal_id':vals.bank_journal_id.id130# 'bank_journal_id':vals.bank_journal_id.id
131 }131# }
132 slip_id = slip_pool.create(cr, uid, res)132# slip_id = slip_pool.create(cr, uid, res)
133 wf_service.trg_validate(uid, 'hr.payslip', slip_id, 'compute_sheet', cr)133# wf_service.trg_validate(uid, 'hr.payslip', slip_id, 'compute_sheet', cr)
134134#
135 number = self.pool.get('ir.sequence').get(cr, uid, 'salary.register')135# number = self.pool.get('ir.sequence').get(cr, uid, 'salary.register')
136 self.write(cr, uid, ids, {'state':'draft', 'number':number})136# self.write(cr, uid, ids, {'state':'draft', 'number':number})
137 return True137# return True
138138#
139payroll_register()139#payroll_register()
140140
141class payroll_advice(osv.osv):141#class payroll_advice(osv.osv):
142 _inherit = 'hr.payroll.advice'142# _inherit = 'hr.payroll.advice'
143 _description = 'Bank Advice Note'143# _description = 'Bank Advice Note'
144144#
145 _columns = {145# _columns = {
146 'account_id': fields.many2one('account.account', 'Account'),146# 'account_id': fields.many2one('account.account', 'Account'),
147 }147# }
148payroll_advice()148#payroll_advice()
149149
150class contrib_register(osv.osv):150class contrib_register(osv.osv):
151 _inherit = 'hr.contibution.register'151 _inherit = 'hr.contribution.register'
152 _description = 'Contribution Register'152 _description = 'Contribution Register'
153153
154 def _total_contrib(self, cr, uid, ids, field_names, arg, context=None):154 def _total_contrib(self, cr, uid, ids, field_names, arg, context=None):
155 line_pool = self.pool.get('hr.contibution.register.line')155# line_pool = self.pool.get('hr.contibution.register.line')
156 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]156 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]
157 fiscalyear_id = self.pool.get('account.period').browse(cr, uid, period_id, context=context).fiscalyear_id157 fiscalyear_id = self.pool.get('account.period').browse(cr, uid, period_id, context=context).fiscalyear_id
158 res = {}158 res = {}
159 for cur in self.browse(cr, uid, ids, context=context):159# for cur in self.browse(cr, uid, ids, context=context):
160 current = line_pool.search(cr, uid, [('period_id','=',period_id),('register_id','=',cur.id)])160# current = line_pool.search(cr, uid, [('period_id','=',period_id),('register_id','=',cur.id)])
161 years = line_pool.search(cr, uid, [('period_id.fiscalyear_id','=',fiscalyear_id.id), ('register_id','=',cur.id)])161# years = line_pool.search(cr, uid, [('period_id.fiscalyear_id','=',fiscalyear_id.id), ('register_id','=',cur.id)])
162162#
163 e_month = 0.0163# e_month = 0.0
164 c_month = 0.0164# c_month = 0.0
165 for i in line_pool.browse(cr, uid, current, context=context):165# for i in line_pool.browse(cr, uid, current, context=context):
166 e_month += i.emp_deduction166# e_month += i.emp_deduction
167 c_month += i.comp_deduction167# c_month += i.comp_deduction
168168#
169 e_year = 0.0169# e_year = 0.0
170 c_year = 0.0170# c_year = 0.0
171 for j in line_pool.browse(cr, uid, years, context=context):171# for j in line_pool.browse(cr, uid, years, context=context):
172 e_year += i.emp_deduction172# e_year += i.emp_deduction
173 c_year += i.comp_deduction173# c_year += i.comp_deduction
174174#
175 res[cur.id]={175# res[cur.id]={
176 'monthly_total_by_emp':e_month,176# 'monthly_total_by_emp':e_month,
177 'monthly_total_by_comp':c_month,177# 'monthly_total_by_comp':c_month,
178 'yearly_total_by_emp':e_year,178# 'yearly_total_by_emp':e_year,
179 'yearly_total_by_comp':c_year179# 'yearly_total_by_comp':c_year
180 }180# }
181 return res181 return res
182182
183 _columns = {183 _columns = {
@@ -188,22 +188,22 @@
188 }188 }
189contrib_register()189contrib_register()
190190
191class contrib_register_line(osv.osv):191#class contrib_register_line(osv.osv):
192 _inherit = 'hr.contibution.register.line'192# _inherit = 'hr.contibution.register.line'
193 _description = 'Contribution Register Line'193# _description = 'Contribution Register Line'
194194#
195 _columns = {195# _columns = {
196 'period_id': fields.many2one('account.period', 'Period'),196# 'period_id': fields.many2one('account.period', 'Period'),
197 }197# }
198contrib_register_line()198#contrib_register_line()
199199
200class hr_holidays_status(osv.osv):200#class hr_holidays_status(osv.osv):
201 _inherit = 'hr.holidays.status'201# _inherit = 'hr.holidays.status'
202 _columns = {202# _columns = {
203 'account_id': fields.many2one('account.account', 'Account'),203# 'account_id': fields.many2one('account.account', 'Account'),
204 'analytic_account_id':fields.many2one('account.analytic.account', 'Analytic Account'),204# 'analytic_account_id':fields.many2one('account.analytic.account', 'Analytic Account'),
205 }205# }
206hr_holidays_status()206#hr_holidays_status()
207207
208class hr_payslip(osv.osv):208class hr_payslip(osv.osv):
209 '''209 '''
@@ -213,14 +213,72 @@
213 _description = 'Pay Slip'213 _description = 'Pay Slip'
214214
215 _columns = {215 _columns = {
216 'journal_id': fields.many2one('account.journal', 'Expense Journal'),216 'journal_id': fields.many2one('account.journal', 'Expense Journal',states={'draft': [('readonly', False)]}, readonly=True),
217 'bank_journal_id': fields.many2one('account.journal', 'Bank Journal'),217 'bank_journal_id': fields.many2one('account.journal', 'Bank Journal', states={'draft': [('readonly', False)]}, readonly=True),
218 'move_ids':fields.one2many('hr.payslip.account.move', 'slip_id', 'Accounting vouchers'),218 'move_ids':fields.one2many('hr.payslip.account.move', 'slip_id', 'Accounting vouchers'),
219 'move_line_ids':fields.many2many('account.move.line', 'payslip_lines_rel', 'slip_id', 'line_id', 'Accounting Lines', readonly=True),219 'move_line_ids':fields.many2many('account.move.line', 'payslip_lines_rel', 'slip_id', 'line_id', 'Accounting Lines', readonly=True),
220 'move_payment_ids':fields.many2many('account.move.line', 'payslip_payment_rel', 'slip_id', 'payment_id', 'Payment Lines', readonly=True),220 'move_payment_ids':fields.many2many('account.move.line', 'payslip_payment_rel', 'slip_id', 'payment_id', 'Payment Lines', readonly=True),
221 'period_id': fields.many2one('account.period', 'Force Period', domain=[('state','<>','done')], help="Keep empty to use the period of the validation(Payslip) date."),221 '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."),
222 'account_move_ids': fields.many2many('account.move', 'payslip_move_rel', 'slip_id', 'move_id', 'Accounting Entries', readonly=True),
222 }223 }
223224
225 def onchange_contract_id(self, cr, uid, ids, date_from, date_to, employee_id=False, contract_id=False, context=None):
226 contract_obj = self.pool.get('hr.contract')
227 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)
228 journal_id = contract_obj.browse(cr, uid, contract_id, context=context).journal_id.id
229 res['value'].update({'journal_id': journal_id})
230 return res
231
232# def onchange_employee_id(self, cr, uid, ids, date_from, date_to, employee_id=False, contract_id=False, context=None):
233# contract_obj = self.pool.get('hr.contract')
234# 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)
235# contract_id = res['value']['contract_id']
236# if res['value']['contract_id']:
237# journal_id = contract_obj.browse(cr, uid, res['value']['contract_id'], context=context).journal_id.id
238# res['value'].update({'journal_id': journal_id})
239# return res
240
241 def get_payslip_lines(self, cr, uid, contract_ids, payslip_id, context):
242 journal_obj = self.pool.get('account.journal')
243 rule_obj = self.pool.get('hr.salary.rule')
244 contract_obj = self.pool.get('hr.contract')
245 structure_obj = self.pool.get('hr.payroll.structure')
246 vals_account = {}
247 result = super(hr_payslip, self).get_payslip_lines(cr, uid, contract_ids, payslip_id, context)
248 structure_ids = contract_obj.get_all_structures(cr, uid, contract_ids, context=context)
249 #get the rules of the structure and thier children
250 rule_ids = structure_obj.get_all_rules(cr, uid, structure_ids, context=context)
251 sorted_rule_ids = [id for id, sequence in sorted(rule_ids, key=lambda x:x[1])]
252 #Fetching Debit/Credit account of the payslip journal.
253 journal = self.browse(cr, uid, payslip_id, context=context).journal_id
254 credit_account = journal.default_credit_account_id and journal.default_credit_account_id.id or False
255 debit_account = journal.default_debit_account_id and journal.default_debit_account_id.id or False
256 # Assigning above fetched Debit/Credit account on salary rules if not specified
257 for rule in rule_obj.browse(cr, uid, sorted_rule_ids, context=context):
258 if not rule.account_debit.id:
259 rule_obj.write(cr, uid, [rule.id], {'account_debit': debit_account})
260 if not rule.account_credit.id:
261 rule_obj.write(cr, uid, [rule.id], {'account_credit': credit_account})
262 #Assigning Debit/Credit account on payslip lines
263 for value in result:
264 if value['salary_rule_id'] == rule.id:
265 if rule.category_id.name == 'Deduction':
266 if not rule.account_debit.id:
267 value['account_id'] = debit_account
268 else:
269 value['account_id'] = rule.account_debit.id
270 elif rule.category_id.name == 'Allowance':
271 if not rule.account_credit.id:
272 value['account_id'] = credit_account
273 else:
274 value['account_id'] = rule.account_credit.id
275 else:
276 emp_account_id = self.browse(cr, uid, payslip_id, context=context).employee_id.employee_account.id
277 value['account_id'] = emp_account_id
278 if rule.analytic_account_id:
279 value['analytic_account_id'] = rule.analytic_account_id.id
280 return result
281
224 def create_voucher(self, cr, uid, ids, name, voucher, sequence=5):282 def create_voucher(self, cr, uid, ids, name, voucher, sequence=5):
225 slip_move = self.pool.get('hr.payslip.account.move')283 slip_move = self.pool.get('hr.payslip.account.move')
226 for slip in ids:284 for slip in ids:
@@ -243,10 +301,8 @@
243 if line.move_id.state == 'posted':301 if line.move_id.state == 'posted':
244 move_pool.button_cancel(cr, uid [line.move_id.id], context)302 move_pool.button_cancel(cr, uid [line.move_id.id], context)
245 move_pool.unlink(cr, uid, [line.move_id.id], context=context)303 move_pool.unlink(cr, uid, [line.move_id.id], context=context)
246
247 slip_move.unlink(cr, uid, move_ids, context=context)304 slip_move.unlink(cr, uid, move_ids, context=context)
248 self.write(cr, uid, ids, {'state':'cancel'}, context=context)305 return self.write(cr, uid, ids, {'state':'cancel'}, context=context)
249 return True
250306
251 def process_sheet(self, cr, uid, ids, context=None):307 def process_sheet(self, cr, uid, ids, context=None):
252 move_pool = self.pool.get('account.move')308 move_pool = self.pool.get('account.move')
@@ -268,17 +324,21 @@
268 partner = slip.employee_id.bank_account_id.partner_id324 partner = slip.employee_id.bank_account_id.partner_id
269 partner_id = partner.id325 partner_id = partner.id
270326
327 for line in slip.line_ids:
328 if line.category_id.code == 'NET':
329 amt = line.total
330
271 fiscal_year_ids = fiscalyear_pool.search(cr, uid, [], context=context)331 fiscal_year_ids = fiscalyear_pool.search(cr, uid, [], context=context)
272 if not fiscal_year_ids:332 if not fiscal_year_ids:
273 raise osv.except_osv(_('Warning !'), _('Please define fiscal year for perticular contract'))333 raise osv.except_osv(_('Warning !'), _('Please define fiscal year for perticular contract'))
274 fiscal_year_objs = fiscalyear_pool.read(cr, uid, fiscal_year_ids, ['date_start','date_stop'], context=context)334 fiscal_year_objs = fiscalyear_pool.read(cr, uid, fiscal_year_ids, ['date_start','date_stop'], context=context)
275 year_exist = False335 year_exist = False
276 for fiscal_year in fiscal_year_objs:336 for fiscal_year in fiscal_year_objs:
277 if ((fiscal_year['date_start'] <= slip.date) and (fiscal_year['date_stop'] >= slip.date)):337 if ((fiscal_year['date_start'] <= slip.date_from) and (fiscal_year['date_stop'] >= slip.date_to)):
278 year_exist = True338 year_exist = True
279 if not year_exist:339 if not year_exist:
280 raise osv.except_osv(_('Warning !'), _('Fiscal Year is not defined for slip date %s') % slip.date)340 raise osv.except_osv(_('Warning !'), _('Fiscal Year is not defined for slip date %s') % slip.date)
281 search_periods = period_pool.search(cr, uid, [('date_start','<=',slip.date),('date_stop','>=',slip.date)], context=context)341 search_periods = period_pool.search(cr, uid, [('date_start','<=',slip.date_from),('date_stop','>=',slip.date_to)], context=context)
282 if not search_periods:342 if not search_periods:
283 raise osv.except_osv(_('Warning !'), _('Period is not defined for slip date %s') % slip.date)343 raise osv.except_osv(_('Warning !'), _('Period is not defined for slip date %s') % slip.date)
284 period_id = search_periods[0]344 period_id = search_periods[0]
@@ -286,7 +346,7 @@
286 move = {346 move = {
287 'journal_id': slip.bank_journal_id.id,347 'journal_id': slip.bank_journal_id.id,
288 'period_id': period_id,348 'period_id': period_id,
289 'date': slip.date,349 'date': slip.date_from,
290 'type':'bank_pay_voucher',350 'type':'bank_pay_voucher',
291 'ref':slip.number,351 'ref':slip.number,
292 'narration': name352 'narration': name
@@ -302,10 +362,10 @@
302 ded_rec = {362 ded_rec = {
303 'move_id': move_id,363 'move_id': move_id,
304 'name': name,364 'name': name,
305 'date': slip.date,365 'date': slip.date_from,
306 'account_id': slip.employee_id.property_bank_account.id,366 'account_id': slip.employee_id.property_bank_account.id,
307 'debit': 0.0,367 'debit': 0.0,
308 'credit': slip.total_pay,368 'credit': amt,
309 'journal_id': slip.journal_id.id,369 'journal_id': slip.journal_id.id,
310 'period_id': period_id,370 'period_id': period_id,
311 'ref': slip.number371 'ref': slip.number
@@ -316,9 +376,9 @@
316 'move_id': move_id,376 'move_id': move_id,
317 'name': name,377 'name': name,
318 'partner_id': partner_id,378 'partner_id': partner_id,
319 'date': slip.date,379 'date': slip.date_from,
320 'account_id': partner.property_account_payable.id,380 'account_id': partner.property_account_payable.id,
321 'debit': slip.total_pay,381 'debit': amt,
322 'credit': 0.0,382 'credit': 0.0,
323 'journal_id': slip.journal_id.id,383 'journal_id': slip.journal_id.id,
324 'period_id': period_id,384 'period_id': period_id,
@@ -326,74 +386,75 @@
326 }386 }
327 line_ids += [movel_pool.create(cr, uid, cre_rec, context=context)]387 line_ids += [movel_pool.create(cr, uid, cre_rec, context=context)]
328388
329 other_pay = slip.other_pay389# other_pay = slip.other_pay
330 #Process all Reambuse Entries390 #Process all Reambuse Entries
331 for line in slip.line_ids:391# for line in slip.line_ids:
332 if line.type == 'otherpay' and line.expanse_id.invoice_id:392# if line.type == 'otherpay' and line.expanse_id.invoice_id:
333 if not line.expanse_id.invoice_id.move_id:393# if not line.expanse_id.invoice_id.move_id:
334 raise osv.except_osv(_('Warning !'), _('Please Confirm all Expense Invoice appear for Reimbursement'))394# raise osv.except_osv(_('Warning !'), _('Please Confirm all Expense Invoice appear for Reimbursement'))
335 invids = [line.expanse_id.invoice_id.id]395# invids = [line.expanse_id.invoice_id.id]
336 amount = line.total396# amount = line.total
337 acc_id = slip.bank_journal_id.default_credit_account_id and slip.bank_journal_id.default_credit_account_id.id397# acc_id = slip.bank_journal_id.default_credit_account_id and slip.bank_journal_id.default_credit_account_id.id
338 period_id = slip.period_id.id398# period_id = slip.period_id.id
339 journal_id = slip.bank_journal_id.id399# journal_id = slip.bank_journal_id.id
340 name = '[%s]-%s' % (slip.number, line.name)400# name = '[%s]-%s' % (slip.number, line.name)
341 invoice_pool.pay_and_reconcile(cr, uid, invids, amount, acc_id, period_id, journal_id, False, period_id, False, context, name)401# invoice_pool.pay_and_reconcile(cr, uid, invids, amount, acc_id, period_id, journal_id, False, period_id, False, context, name)
342 other_pay -= amount402# other_pay -= amount
343 #TODO: link this account entries to the Payment Lines also Expense Entries to Account Lines403# #TODO: link this account entries to the Payment Lines also Expense Entries to Account Lines
344 l_ids = movel_pool.search(cr, uid, [('name','=',name)], context=context)404# l_ids = movel_pool.search(cr, uid, [('name','=',name)], context=context)
345 line_ids += l_ids405# line_ids += l_ids
346406#
347 l_ids = movel_pool.search(cr, uid, [('invoice','=',line.expanse_id.invoice_id.id)], context=context)407# l_ids = movel_pool.search(cr, uid, [('invoice','=',line.expanse_id.invoice_id.id)], context=context)
348 exp_ids += l_ids408# exp_ids += l_ids
349409
350 #Process for Other payment if any410 #Process for Other payment if any
351 other_move_id = False411# other_move_id = False
352 if slip.other_pay > 0:412# if slip.other_pay > 0:
353 narration = 'Payment of Other Payeble amounts to %s' % (slip.employee_id.name)413# narration = 'Payment of Other Payeble amounts to %s' % (slip.employee_id.name)
354 move = {414# move = {
355 'journal_id': slip.bank_journal_id.id,415# 'journal_id': slip.bank_journal_id.id,
356 'period_id': period_id,416# 'period_id': period_id,
357 'date': slip.date,417# 'date': slip.date_from,
358 'type':'bank_pay_voucher',418# 'type':'bank_pay_voucher',
359 'ref':slip.number,419# 'ref':slip.number,
360 'narration': narration420# 'narration': narration
361 }421# }
362 other_move_id = move_pool.create(cr, uid, move, context=context)422# other_move_id = move_pool.create(cr, uid, move, context=context)
363 self.create_voucher(cr, uid, [slip.id], narration, move_id)423# self.create_voucher(cr, uid, [slip.id], narration, move_id)
364424#
365 name = "To %s account" % (slip.employee_id.name)425# name = "To %s account" % (slip.employee_id.name)
366 ded_rec = {426# ded_rec = {
367 'move_id':other_move_id,427# 'move_id':other_move_id,
368 'name':name,428# 'name':name,
369 'date':slip.date,429# 'date':slip.date_from,
370 'account_id':slip.employee_id.property_bank_account.id,430# 'account_id':slip.employee_id.property_bank_account.id,
371 'debit': 0.0,431# 'debit': 0.0,
372 'credit': other_pay,432# 'credit': other_pay,
373 'journal_id':slip.journal_id.id,433# 'journal_id':slip.journal_id.id,
374 'period_id':period_id,434# 'period_id':period_id,
375 'ref':slip.number435# 'ref':slip.number
376 }436# }
377 line_ids += [movel_pool.create(cr, uid, ded_rec, context=context)]437# line_ids += [movel_pool.create(cr, uid, ded_rec, context=context)]
378 name = "By %s account" % (slip.employee_id.property_bank_account.name)438# name = "By %s account" % (slip.employee_id.property_bank_account.name)
379 cre_rec = {439# cre_rec = {
380 'move_id':other_move_id,440# 'move_id':other_move_id,
381 'name':name,441# 'name':name,
382 'partner_id':partner_id,442# 'partner_id':partner_id,
383 'date':slip.date,443# 'date':slip.date_from,
384 'account_id':partner.property_account_payable.id,444# 'account_id':partner.property_account_payable.id,
385 'debit': other_pay,445# 'debit': other_pay,
386 'credit':0.0,446# 'credit':0.0,
387 'journal_id':slip.journal_id.id,447# 'journal_id':slip.journal_id.id,
388 'period_id':period_id,448# 'period_id':period_id,
389 'ref':slip.number449# 'ref':slip.number
390 }450# }
391 line_ids += [movel_pool.create(cr, uid, cre_rec, context=context)]451# line_ids += [movel_pool.create(cr, uid, cre_rec, context=context)]
392452
393 rec = {453 rec = {
394 'state':'done',454 'state':'done',
395 'move_payment_ids':[(6, 0, line_ids)],455 'move_payment_ids':[(6, 0, line_ids)],
396 'paid':True456 'paid':True,
457 'account_move_ids': [(4, move_id)],
397 }458 }
398 self.write(cr, uid, [slip.id], rec, context=context)459 self.write(cr, uid, [slip.id], rec, context=context)
399 for exp_id in exp_ids:460 for exp_id in exp_ids:
@@ -402,12 +463,10 @@
402 return True463 return True
403464
404 def account_check_sheet(self, cr, uid, ids, context=None):465 def account_check_sheet(self, cr, uid, ids, context=None):
405 self.write(cr, uid, ids, {'state':'accont_check'}, context=context)466 return self.write(cr, uid, ids, {'state':'accont_check'}, context=context)
406 return True
407467
408 def hr_check_sheet(self, cr, uid, ids, context=None):468 def hr_check_sheet(self, cr, uid, ids, context=None):
409 self.write(cr, uid, ids, {'state':'hr_check'}, context=context)469 return self.write(cr, uid, ids, {'state':'hr_check'}, context=context)
410 return True
411470
412 def verify_sheet(self, cr, uid, ids, context=None):471 def verify_sheet(self, cr, uid, ids, context=None):
413 move_pool = self.pool.get('account.move')472 move_pool = self.pool.get('account.move')
@@ -419,6 +478,9 @@
419 payslip_pool = self.pool.get('hr.payslip.line')478 payslip_pool = self.pool.get('hr.payslip.line')
420479
421 for slip in self.browse(cr, uid, ids, context=context):480 for slip in self.browse(cr, uid, ids, context=context):
481 for line in slip.line_ids:
482 if line.category_id.code == 'BASIC':
483 basic_amt = line.total
422 if not slip.journal_id:484 if not slip.journal_id:
423 # Call super method to verify sheet if journal_id is not specified.485 # Call super method to verify sheet if journal_id is not specified.
424 super(hr_payslip, self).verify_sheet(cr, uid, [slip.id], context=context)486 super(hr_payslip, self).verify_sheet(cr, uid, [slip.id], context=context)
@@ -426,6 +488,7 @@
426 total_deduct = 0.0488 total_deduct = 0.0
427489
428 line_ids = []490 line_ids = []
491 move_ids = []
429 partner = False492 partner = False
430 partner_id = False493 partner_id = False
431494
@@ -449,11 +512,11 @@
449 fiscal_year_objs = fiscalyear_pool.read(cr, uid, fiscal_year_ids, ['date_start','date_stop'], context=context)512 fiscal_year_objs = fiscalyear_pool.read(cr, uid, fiscal_year_ids, ['date_start','date_stop'], context=context)
450 year_exist = False513 year_exist = False
451 for fiscal_year in fiscal_year_objs:514 for fiscal_year in fiscal_year_objs:
452 if ((fiscal_year['date_start'] <= slip.date) and (fiscal_year['date_stop'] >= slip.date)):515 if ((fiscal_year['date_start'] <= slip.date_from) and (fiscal_year['date_stop'] >= slip.date_to)):
453 year_exist = True516 year_exist = True
454 if not year_exist:517 if not year_exist:
455 raise osv.except_osv(_('Warning !'), _('Fiscal Year is not defined for slip date %s') % slip.date)518 raise osv.except_osv(_('Warning !'), _('Fiscal Year is not defined for slip date %s') % slip.date)
456 search_periods = period_pool.search(cr,uid,[('date_start','<=',slip.date),('date_stop','>=',slip.date)], context=context)519 search_periods = period_pool.search(cr,uid,[('date_start','=',slip.date_from),('date_stop','=',slip.date_to)], context=context)
457 if not search_periods:520 if not search_periods:
458 raise osv.except_osv(_('Warning !'), _('Period is not defined for slip date %s') % slip.date)521 raise osv.except_osv(_('Warning !'), _('Period is not defined for slip date %s') % slip.date)
459 period_id = search_periods[0]522 period_id = search_periods[0]
@@ -461,11 +524,12 @@
461 move = {524 move = {
462 'journal_id': slip.journal_id.id,525 'journal_id': slip.journal_id.id,
463 'period_id': period_id,526 'period_id': period_id,
464 'date': slip.date,527 'date': slip.date_from,
465 'ref':slip.number,528 'ref':slip.number,
466 'narration': slip.name529 'narration': slip.name
467 }530 }
468 move_id = move_pool.create(cr, uid, move, context=context)531 move_id = move_pool.create(cr, uid, move, context=context)
532 move_ids += [move_id]
469 self.create_voucher(cr, uid, [slip.id], slip.name, move_id)533 self.create_voucher(cr, uid, [slip.id], slip.name, move_id)
470534
471 if not slip.employee_id.salary_account.id:535 if not slip.employee_id.salary_account.id:
@@ -474,17 +538,16 @@
474 line = {538 line = {
475 'move_id':move_id,539 'move_id':move_id,
476 'name': "By Basic Salary / " + slip.employee_id.name,540 'name': "By Basic Salary / " + slip.employee_id.name,
477 'date': slip.date,541 'date': slip.date_from,
478 'account_id': slip.employee_id.salary_account.id,542 'account_id': slip.employee_id.salary_account.id,
479 'debit': slip.basic,543 'debit': basic_amt,
480 'credit': 0.0,544 'credit': 0.0,
481 'quantity':slip.working_days,545# 'quantity':slip.working_days,
482 'journal_id': slip.journal_id.id,546 'journal_id': slip.journal_id.id,
483 'period_id': period_id,547 'period_id': period_id,
484 'analytic_account_id': False,548 'analytic_account_id': False,
485 'ref':slip.number549 'ref':slip.number
486 }550 }
487
488 #Setting Analysis Account for Basic Salary551 #Setting Analysis Account for Basic Salary
489 if slip.employee_id.analytic_account:552 if slip.employee_id.analytic_account:
490 line['analytic_account_id'] = slip.employee_id.analytic_account.id553 line['analytic_account_id'] = slip.employee_id.analytic_account.id
@@ -499,28 +562,30 @@
499 'move_id':move_id,562 'move_id':move_id,
500 'name': "To Basic Payble Salary / " + slip.employee_id.name,563 'name': "To Basic Payble Salary / " + slip.employee_id.name,
501 'partner_id': partner_id,564 'partner_id': partner_id,
502 'date': slip.date,565 'date': slip.date_from,
503 'account_id': slip.employee_id.employee_account.id,566 'account_id': slip.employee_id.employee_account.id,
504 'debit': 0.0,567 'debit': 0.0,
505 'quantity':slip.working_days,568# 'quantity':slip.working_days,
506 'credit': slip.basic,569 'credit': basic_amt,
507 'journal_id': slip.journal_id.id,570 'journal_id': slip.journal_id.id,
508 'period_id': period_id,571 'period_id': period_id,
509 'ref':slip.number572 'ref':slip.number
510 }573 }
511 line_ids += [movel_pool.create(cr, uid, line, context=context)]574 line_ids += [movel_pool.create(cr, uid, line, context=context)]
512575 codes = ['NET', 'GROSS', 'BASIC']
513 for line in slip.line_ids:576 for line in slip.line_ids:
577 if line.code in codes:
578 continue
514 name = "[%s] - %s / %s" % (line.code, line.name, slip.employee_id.name)579 name = "[%s] - %s / %s" % (line.code, line.name, slip.employee_id.name)
515 amount = line.total580 amount = line.total
516581
517 if line.type == 'leaves':582# if line.type == 'leaves':
518 continue583# continue
519584
520 rec = {585 rec = {
521 'move_id': move_id,586 'move_id': move_id,
522 'name': name,587 'name': name,
523 'date': slip.date,588 'date': slip.date_from,
524 'account_id': line.account_id.id,589 'account_id': line.account_id.id,
525 'debit': 0.0,590 'debit': 0.0,
526 'credit': 0.0,591 'credit': 0.0,
@@ -534,10 +599,11 @@
534 #Setting Analysis Account for Salary Slip Lines599 #Setting Analysis Account for Salary Slip Lines
535 if line.analytic_account_id:600 if line.analytic_account_id:
536 rec['analytic_account_id'] = line.analytic_account_id.id601 rec['analytic_account_id'] = line.analytic_account_id.id
537 else:602# else:
538 rec['analytic_account_id'] = slip.deg_id.account_id.id603# rec['analytic_account_id'] = slip.deg_id.account_id.id
539604
540 if line.type == 'allowance' or line.type == 'otherpay':605# if line.type == 'allowance' or line.type == 'otherpay':
606 if line.category_id.code == 'ALW' :
541 rec['debit'] = amount607 rec['debit'] = amount
542 if not partner.property_account_payable:608 if not partner.property_account_payable:
543 raise osv.except_osv(_('Integrity Error !'), _('Please Configure Partners Payable Account!!'))609 raise osv.except_osv(_('Integrity Error !'), _('Please Configure Partners Payable Account!!'))
@@ -545,7 +611,7 @@
545 'move_id': move_id,611 'move_id': move_id,
546 'name': name,612 'name': name,
547 'partner_id': partner_id,613 'partner_id': partner_id,
548 'date': slip.date,614 'date': slip.date_from,
549 'account_id': partner.property_account_payable.id,615 'account_id': partner.property_account_payable.id,
550 'debit': 0.0,616 'debit': 0.0,
551 'quantity': 1,617 'quantity': 1,
@@ -555,16 +621,17 @@
555 'ref': slip.number621 'ref': slip.number
556 }622 }
557 line_ids += [movel_pool.create(cr, uid, ded_rec, context=context)]623 line_ids += [movel_pool.create(cr, uid, ded_rec, context=context)]
558 elif line.type == 'deduction' or line.type == 'otherdeduct':624 elif line.category_id.code == 'DED':
559 if not partner.property_account_receivable:625 if not partner.property_account_receivable:
560 raise osv.except_osv(_('Integrity Error !'), _('Please Configure Partners Receivable Account!!'))626 raise osv.except_osv(_('Integrity Error !'), _('Please Configure Partners Receivable Account!!'))
627 amount = -(amount)
561 rec['credit'] = amount628 rec['credit'] = amount
562 total_deduct += amount629 total_deduct += amount
563 ded_rec = {630 ded_rec = {
564 'move_id': move_id,631 'move_id': move_id,
565 'name': name,632 'name': name,
566 'partner_id': partner_id,633 'partner_id': partner_id,
567 'date': slip.date,634 'date': slip.date_from,
568 'quantity': 1,635 'quantity': 1,
569 'account_id': partner.property_account_receivable.id,636 'account_id': partner.property_account_receivable.id,
570 'debit': amount,637 'debit': amount,
@@ -574,23 +641,21 @@
574 'ref': slip.number641 'ref': slip.number
575 }642 }
576 line_ids += [movel_pool.create(cr, uid, ded_rec, context=context)]643 line_ids += [movel_pool.create(cr, uid, ded_rec, context=context)]
577
578 line_ids += [movel_pool.create(cr, uid, rec, context=context)]644 line_ids += [movel_pool.create(cr, uid, rec, context=context)]
579
580 # if self._debug:645 # if self._debug:
581 # for contrib in line.category_id.contribute_ids:646 # for contrib in line.category_id.contribute_ids:
582 # _log.debug("%s %s %s %s %s", contrib.name, contrub.code, contrub.amount_type, contrib.contribute_per, line.total)647 # _log.debug("%s %s %s %s %s", contrib.name, contrub.code, contrub.amount_type, contrib.contribute_per, line.total)
583
584 adj_move_id = False648 adj_move_id = False
585 if total_deduct > 0:649 if total_deduct > 0:
586 move = {650 move = {
587 'journal_id': slip.journal_id.id,651 'journal_id': slip.journal_id.id,
588 'period_id': period_id,652 'period_id': period_id,
589 'date': slip.date,653 'date': slip.date_from,
590 'ref':slip.number,654 'ref':slip.number,
591 'narration': 'Adjustment: %s' % (slip.name)655 'narration': 'Adjustment: %s' % (slip.name)
592 }656 }
593 adj_move_id = move_pool.create(cr, uid, move, context=context)657 adj_move_id = move_pool.create(cr, uid, move, context=context)
658 move_ids += [adj_move_id]
594 name = "Adjustment Entry - %s" % (slip.employee_id.name)659 name = "Adjustment Entry - %s" % (slip.employee_id.name)
595 self.create_voucher(cr, uid, [slip.id], name, adj_move_id)660 self.create_voucher(cr, uid, [slip.id], name, adj_move_id)
596661
@@ -598,7 +663,7 @@
598 'move_id': adj_move_id,663 'move_id': adj_move_id,
599 'name': name,664 'name': name,
600 'partner_id': partner_id,665 'partner_id': partner_id,
601 'date': slip.date,666 'date': slip.date_from,
602 'account_id': partner.property_account_receivable.id,667 'account_id': partner.property_account_receivable.id,
603 'debit': 0.0,668 'debit': 0.0,
604 'quantity': 1,669 'quantity': 1,
@@ -612,7 +677,7 @@
612 'move_id': adj_move_id,677 'move_id': adj_move_id,
613 'name': name,678 'name': name,
614 'partner_id': partner_id,679 'partner_id': partner_id,
615 'date': slip.date,680 'date': slip.date_from,
616 'account_id': partner.property_account_payable.id,681 'account_id': partner.property_account_payable.id,
617 'debit': total_deduct,682 'debit': total_deduct,
618 'quantity': 1,683 'quantity': 1,
@@ -626,29 +691,28 @@
626 rec = {691 rec = {
627 'state':'confirm',692 'state':'confirm',
628 'move_line_ids':[(6, 0,line_ids)],693 'move_line_ids':[(6, 0,line_ids)],
694 'account_move_ids':[(6, 0, move_ids)]
629 }695 }
630 if not slip.period_id:696 if not slip.period_id:
631 rec['period_id'] = period_id697 rec['period_id'] = period_id
632698
633 dates = prev_bounds(slip.date)699# dates = prev_bounds(slip.date)
634 exp_ids = exp_pool.search(cr, uid, [('date_valid','>=',dates[0]), ('date_valid','<=',dates[1]), ('state','=','invoiced')], context=context)700 exp_ids = exp_pool.search(cr, uid, [('date_valid','>=',slip.date_from), ('date_valid','<=',slip.date_to), ('state','=','invoiced')], context=context)
635 if exp_ids:701# if exp_ids:
636 acc = property_pool.get(cr, uid, 'property_account_expense_categ', 'product.category')702# acc = property_pool.get(cr, uid, 'property_account_expense_categ', 'product.category')
637 for exp in exp_pool.browse(cr, uid, exp_ids, context=context):703# for exp in exp_pool.browse(cr, uid, exp_ids, context=context):
638 exp_res = {704# exp_res = {
639 'name':exp.name,705# 'name':exp.name,
640 'amount_type':'fix',706# 'amount_type':'fix',
641 'type':'otherpay',707# 'type':'otherpay',
642 'category_id':exp.category_id.id,708# 'category_id':exp.category_id.id,
643 'amount':exp.amount,709# 'amount':exp.amount,
644 'slip_id':slip.id,710# 'slip_id':slip.id,
645 'expanse_id':exp.id,711# 'expanse_id':exp.id,
646 'account_id':acc712# 'account_id':acc
647 }713# }
648 payslip_pool.create(cr, uid, exp_res, context=context)714# payslip_pool.create(cr, uid, exp_res, context=context)
649
650 self.write(cr, uid, [slip.id], rec, context=context)715 self.write(cr, uid, [slip.id], rec, context=context)
651
652 return True716 return True
653717
654hr_payslip()718hr_payslip()
@@ -661,6 +725,17 @@
661 }725 }
662hr_payslip_line()726hr_payslip_line()
663727
728class hr_salary_rule(osv.osv):
729 _inherit = 'hr.salary.rule'
730 _columns = {
731# 'account_id': fields.many2one('account.account', 'General Account'),
732 'analytic_account_id':fields.many2one('account.analytic.account', 'Analytic Account'),
733 'account_tax_id':fields.many2one('account.tax.code', 'Tax Code'),
734 'account_debit': fields.many2one('account.account', 'Debit Account'),
735 'account_credit': fields.many2one('account.account', 'Credit Account'),
736 }
737hr_salary_rule()
738
664class account_move_link_slip(osv.osv):739class account_move_link_slip(osv.osv):
665 '''740 '''
666 Account Move Link to Pay Slip741 Account Move Link to Pay Slip
@@ -675,4 +750,15 @@
675 }750 }
676account_move_link_slip()751account_move_link_slip()
677752
753class hr_contract(osv.osv):
754
755 _inherit = 'hr.contract'
756 _description = 'Employee Contract'
757 _columns = {
758 'analytic_account_id':fields.many2one('account.analytic.account', 'Analytic Account'),
759 'journal_id': fields.many2one('account.journal', 'Journal'),
760 }
761hr_contract()
762
763
678# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:764# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
679765
=== 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 @@
2<openerp>2<openerp>
3 <data>3 <data>
44
5 <record id="hr_payroll.hr_payslip_line_houserantallowance1" model="hr.payslip.line">5 <record id="hr_payroll.hr_payslip_line_houserantallowance1" model="hr.salary.rule">
6 <field name="account_id" ref="account.a_salary_expense"/>6 <field name="account_debit" ref="account.a_salary_expense"/>
7 </record>7 </record>
88
9 <record id="hr_payroll.hr_payslip_line_convanceallowance1" model="hr.payslip.line">9 <record id="hr_payroll.hr_payslip_line_convanceallowance1" model="hr.salary.rule">
10 <field name="account_id" ref="account.a_salary_expense"/>10 <field name="account_debit" ref="account.a_salary_expense"/>
11 </record>11 </record>
1212
13 <record id="hr_payroll.hr_payslip_line_professionaltax1" model="hr.payslip.line">13 <record id="hr_payroll.hr_payslip_line_professionaltax1" model="hr.salary.rule">
14 <field name="account_id" ref="account.a_salary_expense"/>14 <field name="account_debit" ref="account.a_salary_expense"/>
15 </record>15 </record>
1616
17 <record id="hr_payroll.hr_payslip_line_providentfund1" model="hr.payslip.line">17 <record id="hr_payroll.hr_payslip_line_providentfund1" model="hr.salary.rule">
18 <field name="account_id" ref="account.a_salary_expense"/>18 <field name="account_debit" ref="account.a_salary_expense"/>
19 </record>
20
21 <record id="hr_payroll.hr_salary_rule_meal_voucher" model="hr.salary.rule">
22 <field name="account_debit" ref="account.a_salary_expense"/>
23 </record>
24
25 <record id="hr_payroll.hr_salary_rule_ca_paolino" model="hr.salary.rule">
26 <field name="account_debit" ref="account.a_salary_expense"/>
27 </record>
28
29 <record id="hr_payroll.hr_rule_basic" model="hr.salary.rule">
30 <field name="account_debit" ref="account.a_salary_expense"/>
31 </record>
32
33 <record id="hr_payroll.hr_rule_taxable" model="hr.salary.rule">
34 <field name="account_debit" ref="account.a_salary_expense"/>
35 </record>
36
37 <record id="hr_payroll.hr_rule_net" model="hr.salary.rule">
38 <field name="account_debit" ref="account.a_salary_expense"/>
39 </record>
40
41 <record id="hr_payroll.hr_payslip_line_houserantallowance1" model="hr.salary.rule">
42 <field name="account_debit" ref="account.a_salary_expense"/>
19 </record>43 </record>
2044
21 <!-- Payslip -->45 <!-- Payslip -->
22 <record id="hr_payroll.hr_payslip_salaryslipofbonamyforjune0" model="hr.payslip">46 <!-- <record id="hr_payroll.hr_payslip_salaryslipofbonamyforjune0" model="hr.payslip">
23 <field name="journal_id" ref="account.expenses_journal"/>47 <field name="journal_id" ref="account.expenses_journal"/>
24 <field name="bank_journal_id" ref="account.bank_journal"/>48 <field name="bank_journal_id" ref="account.bank_journal"/>
25 </record>49 </record>-->
2650
27 <!-- Assigned Default Account in Different Demo Employees -->51 <!-- Assigned Default Account in Different Demo Employees -->
2852
29 <!--record id="hr.employee" model="hr.employee">53 <!-- <record id="hr.employee" model="hr.employee">
30 <field name="property_bank_account" ref="account.bnk"/>54 <field name="property_bank_account" ref="account.bnk"/>
31 <field name="salary_account" ref="account.a_salary_expense"/>55 <field name="salary_account" ref="account.a_salary_expense"/>
32 <field name="employee_account" ref="account.a_expense"/>56 <field name="employee_account" ref="account.a_expense"/>
@@ -54,7 +78,7 @@
54 <field name="property_bank_account" ref="account.bnk"/>78 <field name="property_bank_account" ref="account.bnk"/>
55 <field name="salary_account" ref="account.a_salary_expense"/>79 <field name="salary_account" ref="account.a_salary_expense"/>
56 <field name="employee_account" ref="account.a_expense"/>80 <field name="employee_account" ref="account.a_expense"/>
57 </record-->81 </record>-->
5882
59 <record id="bnk" model="account.account">83 <record id="bnk" model="account.account">
60 <field name="code">X110041</field>84 <field name="code">X110041</field>
@@ -72,12 +96,13 @@
72 <field name="user_type" ref="account.account_type_expense"/>96 <field name="user_type" ref="account.account_type_expense"/>
73 </record>97 </record>
7498
75 <record id="a_expense" model="account.account">99 <record id="a_creditors" model="account.account">
76 <field name="code">X21102</field>100 <field name="code">X11111</field>
77 <field name="name">Expenses</field>101 <field name="name">Employee Payable Account</field>
78 <field ref="account.ovr" name="parent_id"/>102 <field ref="account.cli" name="parent_id"/>
79 <field name="type">other</field>103 <field name="type">payable</field>
80 <field name="user_type" ref="account.account_type_expense"/>104 <field eval="True" name="reconcile"/>
105 <field name="user_type" ref="account.account_type_payable"/>
81 </record>106 </record>
82107
83 <!-- Properties -->108 <!-- Properties -->
@@ -98,7 +123,7 @@
98 <record forcecreate="True" id="employee_account" model="ir.property">123 <record forcecreate="True" id="employee_account" model="ir.property">
99 <field name="name">employee_account</field>124 <field name="name">employee_account</field>
100 <field name="fields_id" search="[('model','=','hr.employee'),('name','=','employee_account')]"/>125 <field name="fields_id" search="[('model','=','hr.employee'),('name','=','employee_account')]"/>
101 <field eval="'account.account,'+str(a_expense)" name="value"/>126 <field eval="'account.account,'+str(a_creditors)" name="value"/>
102 <field name="company_id" ref="base.main_company"/>127 <field name="company_id" ref="base.main_company"/>
103 </record>128 </record>
104129
105130
=== 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 @@
2<openerp>2<openerp>
3 <data>3 <data>
44
5
6 <record model="ir.ui.view" id="view_holiday_status_inherit_form1">
7 <field name="name">hr.holidays.status.inherit1</field>
8 <field name="model">hr.holidays.status</field>
9 <field name="inherit_id" ref="hr_payroll.view_holiday_status_form1"/>
10 <field name="type">form</field>
11 <field name="arch" type="xml">
12 <field name="code" position="after">
13 <field name="analytic_account_id"/>
14 <newline/>
15 <field name="account_id"/>
16 <newline/>
17 </field>
18 </field>
19 </record>
20
21 <record model="ir.ui.view" id="view_hr_payslip_line_inherit_tree">5 <record model="ir.ui.view" id="view_hr_payslip_line_inherit_tree">
22 <field name="name">hr.payslip.line.inherit.tree</field>6 <field name="name">hr.payslip.line.inherit.tree</field>
23 <field name="model">hr.payslip.line</field>7 <field name="model">hr.payslip.line</field>
24 <field name="inherit_id" ref="hr_payroll.view_hr_payslip_line_tree"/>8 <field name="inherit_id" ref="hr_payroll.view_hr_payslip_line_tree"/>
25 <field name="type">tree</field>9 <field name="type">tree</field>
26 <field name="arch" type="xml">10 <field name="arch" type="xml">
27 <field name="amount" position="after">11 <field name="category_id" position="after">
28 <field name="analytic_account_id"/>12 <field name="analytic_account_id"/>
29 <field name="account_id" required="1"/>13 <field name="account_id" required="1"/>
30 </field>14 </field>
@@ -44,7 +28,7 @@
44 </field>28 </field>
45 </record>29 </record>
4630
47 <record model="ir.ui.view" id="view_hr_employee_grade_inherit_form">31 <!-- <record model="ir.ui.view" id="view_hr_employee_grade_inherit_form">
48 <field name="name">hr.employee.grade.inherit.form</field>32 <field name="name">hr.employee.grade.inherit.form</field>
49 <field name="model">hr.payroll.structure</field>33 <field name="model">hr.payroll.structure</field>
50 <field name="inherit_id" ref="hr_payroll.view_hr_employee_grade_form"/>34 <field name="inherit_id" ref="hr_payroll.view_hr_employee_grade_form"/>
@@ -54,7 +38,7 @@
54 <field name="account_id" required="1"/>38 <field name="account_id" required="1"/>
55 </xpath>39 </xpath>
56 </field>40 </field>
57 </record>41 </record>-->
5842
59 <record model="ir.ui.view" id="view_hr_payslip_inherit_form">43 <record model="ir.ui.view" id="view_hr_payslip_inherit_form">
60 <field name="name">hr.payslip.inherit.form</field>44 <field name="name">hr.payslip.inherit.form</field>
@@ -62,9 +46,10 @@
62 <field name="inherit_id" ref="hr_payroll.view_hr_payslip_form"/>46 <field name="inherit_id" ref="hr_payroll.view_hr_payslip_form"/>
63 <field name="type">form</field>47 <field name="type">form</field>
64 <field name="arch" type="xml">48 <field name="arch" type="xml">
65 <field name="date" position="before">49 <field name="date_to" position="after">
66 <field name="journal_id" required="1"/>50 <field name="journal_id" required="1"/>
67 <field name="bank_journal_id" domain="[('type','=','cash')]" required="1"/>51 <field name="bank_journal_id" domain="[('type','=','cash')]" required="1"/>
52 <field name="period_id" />
68 </field>53 </field>
69 </field>54 </field>
70 </record>55 </record>
@@ -80,58 +65,20 @@
80 <field name="account_id" required="1"/>65 <field name="account_id" required="1"/>
81 <field name="analytic_account_id"/>66 <field name="analytic_account_id"/>
82 </xpath>67 </xpath>
83 <xpath expr="/form/notebook/page[@string='Salary Computation']/field[@name='line_ids']/form/group/field[@name='company_contrib']" position="before">68 <xpath expr="/form/notebook/page[@string='Salary Computation']/field[@name='line_ids']/form/group/field[@name='salary_rule_id']" position="after">
84 <field name="account_id" required="1"/>69 <field name="account_id" required="1"/>
85 <field name="analytic_account_id"/>70 <field name="analytic_account_id"/>
86 </xpath>71 </xpath>
87 </field>72 </field>
88 </record>73 </record>
8974
90 <record model="ir.ui.view" id="view_hr_bank_advice_inherit_form">
91 <field name="name">hr.payroll.advice.inherit.form</field>
92 <field name="model">hr.payroll.advice</field>
93 <field name="inherit_id" ref="hr_payroll.view_hr_bank_advice_form"/>
94 <field name="type">form</field>
95 <field name="arch" type="xml">
96 <field name="name" position="after">
97 <field name="account_id" required="1"/>
98 </field>
99 </field>
100 </record>
101
102 <record model="ir.ui.view" id="view_hr_payroll_register_inherit_tree">
103 <field name="name">hr.payroll.register.inherit.tree</field>
104 <field name="model">hr.payroll.register</field>
105 <field name="inherit_id" ref="hr_payroll.view_hr_payroll_register_tree"/>
106 <field name="type">tree</field>
107 <field name="arch" type="xml">
108 <field name="state" position="before">
109 <field name="journal_id" required="1"/>
110 <field name="bank_journal_id" required="1"/>
111 </field>
112 </field>
113 </record>
114
115 <record model="ir.ui.view" id="view_hr_payroll_register_inherit_form">
116 <field name="name">hr.payroll.register.inherit.form</field>
117 <field name="model">hr.payroll.register</field>
118 <field name="inherit_id" ref="hr_payroll.view_hr_payroll_register_form"/>
119 <field name="type">form</field>
120 <field name="arch" type="xml">
121 <field name="number" position="after">
122 <field name="journal_id" required="1"/>
123 <field name="bank_journal_id" required="1"/>
124 </field>
125 </field>
126 </record>
127
128 <record model="ir.ui.view" id="hr_contibution_register_inherit_tree">75 <record model="ir.ui.view" id="hr_contibution_register_inherit_tree">
129 <field name="name">hr.contibution.register.inherit.tree</field>76 <field name="name">hr.contribution.register.inherit.tree</field>
130 <field name="model">hr.contibution.register</field>77 <field name="model">hr.contribution.register</field>
131 <field name="inherit_id" ref="hr_payroll.hr_contibution_register_tree"/>78 <field name="inherit_id" ref="hr_payroll.hr_contribution_register_tree"/>
132 <field name="type">tree</field>79 <field name="type">tree</field>
133 <field name="arch" type="xml">80 <field name="arch" type="xml">
134 <field name="monthly_total_by_comp" position="after">81 <field name="name" position="after">
135 <field name="yearly_total_by_emp"/>82 <field name="yearly_total_by_emp"/>
136 <field name="yearly_total_by_comp"/>83 <field name="yearly_total_by_comp"/>
137 </field>84 </field>
@@ -139,45 +86,35 @@
139 </record>86 </record>
14087
141 <record model="ir.ui.view" id="hr_contibution_register_inherit_form">88 <record model="ir.ui.view" id="hr_contibution_register_inherit_form">
142 <field name="name">hr.contibution.register.inherit.form</field>89 <field name="name">hr.contribution.register.inherit.form</field>
143 <field name="model">hr.contibution.register</field>90 <field name="model">hr.contribution.register</field>
144 <field name="inherit_id" ref="hr_payroll.hr_contibution_register_form"/>91 <field name="inherit_id" ref="hr_payroll.hr_contribution_register_form"/>
145 <field name="type">form</field>92 <field name="type">form</field>
146 <field name="arch" type="xml">93 <field name="arch" type="xml">
147 <field name="name" position="after">94 <xpath expr="/form/notebook" position="before">
148 <field name="account_id" required="1"/>95 <newline/>
149 <field name="analytic_account_id"/>96 <field name="account_id" />
150 </field>97 <field name="analytic_account_id"/>
98 </xpath>
151 </field>99 </field>
152 </record>100 </record>
153101
154 <record model="ir.ui.view" id="hr_contibution_register_inherit1_form">102 <!-- <record model="ir.ui.view" id="hr_contibution_register_inherit1_form">
155 <field name="name">hr.contibution.register.inherit1.form</field>103 <field name="name">hr.contribution.register.inherit1.form</field>
156 <field name="model">hr.contibution.register</field>104 <field name="model">hr.contribution.register</field>
157 <field name="inherit_id" ref="hr_payroll.hr_contibution_register_form"/>105 <field name="inherit_id" ref="hr_payroll.hr_contribution_register_form"/>
158 <field name="type">form</field>106 <field name="type">form</field>
159 <field name="arch" type="xml">107 <field name="arch" type="xml">
160 <group name="Month" position="after">108 <xpath expr="/form/notebook" position="before">
161 <group col="2" colspan="2">109 <group col="2" colspan="2">
110 <newline/>
162 <separator colspan="4" string="Year"/>111 <separator colspan="4" string="Year"/>
163 <field name="yearly_total_by_emp"/>112 <field name="yearly_total_by_emp"/>
164 <field name="yearly_total_by_comp"/>113 <field name="yearly_total_by_comp"/>
165 </group>114 </group>
166 </group>115 </xpath>
167 </field>116 </field>
168 </record>117 </record>-->
169
170 <record model="ir.ui.view" id="hr_contibution_register_line_inherit_form">
171 <field name="name">hr.contibution.register.line.form.inherit</field>
172 <field name="model">hr.contibution.register.line</field>
173 <field name="inherit_id" ref="hr_payroll.hr_contibution_register_line_form"/>
174 <field name="type">form</field>
175 <field name="arch" type="xml">
176 <field name="employee_id" position="after">
177 <field name="period_id"/>
178 </field>
179 </field>
180 </record>
181118
182 <record id="view_hr_payslip_form_inherit" model="ir.ui.view">119 <record id="view_hr_payslip_form_inherit" model="ir.ui.view">
183 <field name="name">hr.payslip.form</field>120 <field name="name">hr.payslip.form</field>
@@ -185,7 +122,7 @@
185 <field name="type">form</field>122 <field name="type">form</field>
186 <field name="inherit_id" ref="hr_payroll.view_hr_payslip_form"/>123 <field name="inherit_id" ref="hr_payroll.view_hr_payslip_form"/>
187 <field name="arch" type="xml">124 <field name="arch" type="xml">
188 <page string="Other Informations" position="replace">125 <xpath expr="/form/notebook/page[@string='Other Information']" position="replace">
189 <page string="Accounting Details">126 <page string="Accounting Details">
190 <group col="4" colspan="3">127 <group col="4" colspan="3">
191 <separator colspan="4" string="Accounting Informations"/>128 <separator colspan="4" string="Accounting Informations"/>
@@ -203,37 +140,28 @@
203 </field>140 </field>
204 </group>141 </group>
205 <group col="2" colspan="1">142 <group col="2" colspan="1">
206 <separator colspan="2" string="Other Informations"/>143 <separator colspan="4" string="Other Information"/>
207 <field name="paid" readonly="1"/>144 <group col="5" colspan="2">
208 <field name="company_id"/>145 <field name="company_id" groups="base.group_multi_company" widget="selection"/>
209 <field name="register_id"/>146 <newline/>
210 <field name="deg_id"/>147 <field name="paid" readonly="1"/>
211 <field name="contract_id" domain="[('employee_id','=',employee_id)]"/>148 </group>
212 </group>149 </group>
213 <separator colspan="4" string="Description"/>150 <separator colspan="4" string="Notes"/>
214 <field name="note" colspan="4" nolabel="1"/>151 <field name="note" colspan="4" nolabel="1"/>
215 </page>152 </page>
216 </page>153 <page string="Account Lines">
217 </field>154 <field name="move_line_ids" colspan="4" nolabel="1"/>
218 </record>155 </page>
219156 <page string="Payment Lines">
220 <record id="view_hr_payslip_form_inherit1" model="ir.ui.view">157 <field name="move_payment_ids" colspan="4" nolabel="1"/>
221 <field name="name">hr.payslip.form</field>158 </page>
222 <field name="model">hr.payslip</field>159 <page string="Accounting Entries">
223 <field name="type">form</field>160 <field name="account_move_ids" colspan="4" nolabel="1"/>
224 <field name="inherit_id" ref="view_hr_payslip_form_inherit"/>161 </page>
225 <field name="arch" type="xml">162 </xpath>
226 <notebook position="inside">163 </field>
227 <page string="Account Lines">164 </record>
228 <field name="move_line_ids" colspan="4" nolabel="1"/>
229 </page>
230 <page string="Payment Lines">
231 <field name="move_payment_ids" colspan="4" nolabel="1"/>
232 </page>
233 </notebook>
234 </field>
235 </record>
236
237165
238 <!-- Adding Account Properties to the Employee form -->166 <!-- Adding Account Properties to the Employee form -->
239167
@@ -251,5 +179,39 @@
251 </field>179 </field>
252 </record>180 </record>
253181
182 <!-- Adding Account fields to the Salary Rules -->
183
184 <record id="hr_salary_rule_form_inherit" model="ir.ui.view">
185 <field name="name">hr.salary.rule.form.inherit</field>
186 <field name="model">hr.salary.rule</field>
187 <field name="inherit_id" ref="hr_payroll.hr_salary_rule_form"/>
188 <field name="arch" type="xml">
189 <xpath expr="/form/notebook/page[@string='Child Rules']" position="after">
190 <page string="Accounting">
191 <field name="account_debit" />
192 <field name="account_credit"/>
193 <field name="analytic_account_id"/>
194 <field name="account_tax_id"/>
195 </page>
196 </xpath>
197 </field>
198 </record>
199
200 <!-- Contract View -->
201
202 <record id="hr_contract_form_inherit" model="ir.ui.view">
203 <field name="name">hr.contract.view.form.inherit</field>
204 <field name="model">hr.contract</field>
205 <field name="type">form</field>
206 <field name="inherit_id" ref="hr_contract.hr_contract_view_form"/>
207 <field name="arch" type="xml">
208 <xpath expr="/form/notebook/page/group/field[@name='advantages']" position="after">
209 <separator colspan="4" string="Accounting"/>
210 <field name="analytic_account_id"/>
211 <field name="journal_id"/>
212 </xpath>
213 </field>
214 </record>
215
254 </data>216 </data>
255</openerp>217</openerp>

Subscribers

People subscribed via source and target branches