diff --git a/addons/hr_payroll/hr_payroll.py b/addons/hr_payroll/hr_payroll.py
index 5ba5dbac216..14b66c328d5 100644
--- a/addons/hr_payroll/hr_payroll.py
+++ b/addons/hr_payroll/hr_payroll.py
@@ -278,7 +278,7 @@ class hr_payslip(osv.osv):
'note': fields.text('Description', readonly=True, states={'draft':[('readonly',False)]}),
'contract_id': fields.many2one('hr.contract', 'Contract', required=False, readonly=True, states={'draft': [('readonly', False)]}),
'details_by_salary_rule_category': fields.function(_get_lines_salary_rule_category, method=True, type='one2many', relation='hr.payslip.line', string='Details by Salary Rule Category'),
- 'credit_note': fields.boolean('Credit Note', help="Indicates this payslip has a refund of another"),
+ 'credit_note': fields.boolean('Credit Note', help="Indicates this payslip has a refund of another", readonly=True, states={'draft': [('readonly', False)]}),
'payslip_run_id': fields.many2one('hr.payslip.run', 'Payslip Run', readonly=True, states={'draft': [('readonly', False)]}),
}
_defaults = {
diff --git a/addons/hr_payroll/hr_payroll_demo.xml b/addons/hr_payroll/hr_payroll_demo.xml
index 6408cb78094..bcbecd63ffd 100644
--- a/addons/hr_payroll/hr_payroll_demo.xml
+++ b/addons/hr_payroll/hr_payroll_demo.xml
@@ -2,19 +2,38 @@
+
+
+
+ House Rent Allowance Register
+
+
+
+ Provident Fund Register
+
+
+
+ Professional Tax Register
+
+
+
+ Meal Voucher Register
+
+
-
+
percentage
contract.wage
HRA
+
House Rent Allowance
-
+
fix
CA
@@ -23,22 +42,24 @@
-
+
fix
PT
+
Professional Tax
-
+
percentage
contract.wage
PF
+
Provident Fund
@@ -57,6 +78,7 @@
worked_days.WORK100.number_of_days
MA
+
Meal Voucher
@@ -89,7 +111,7 @@
ME
Marketing Executive
-
+
@@ -103,6 +125,7 @@
+
@@ -113,6 +136,7 @@
+
Marketing Executive Contract
diff --git a/addons/hr_payroll/hr_payroll_view.xml b/addons/hr_payroll/hr_payroll_view.xml
index f8b74ba01ee..1465e29ca40 100644
--- a/addons/hr_payroll/hr_payroll_view.xml
+++ b/addons/hr_payroll/hr_payroll_view.xml
@@ -144,6 +144,8 @@
+
+
@@ -196,6 +198,7 @@
+
@@ -205,7 +208,6 @@
-
hr.payslip.tree
hr.payslip
@@ -523,7 +525,7 @@
id="act_hr_employee_payslip_list"
groups="base.group_hr_manager"/>
-
+
hr.salary.rule.tree
@@ -551,7 +553,7 @@
-
+
@@ -626,69 +628,69 @@
-
+
-
- hr.payslip.run.search
- hr.payslip.run
- search
-
-
-
-
-
-
-
-
-
-
- hr.payslip.run.tree
- hr.payslip.run
- tree
-
-
-
-
-
-
-
-
-
-
- hr.payslip.run.form
- hr.payslip.run
- form
-
-
-
-
+
+
+
-
- Payslips Run
- hr.payslip.run
- form
-
-
-
-
+
+ hr.payslip.run.tree
+ hr.payslip.run
+ tree
+
+
+
+
+
+
+
+
+
+
+ hr.payslip.run.form
+ hr.payslip.run
+ form
+
+
+
+
+
+
+ Payslips Run
+ hr.payslip.run
+ form
+
+
+
+
diff --git a/addons/hr_payroll/report/report_contribution_register.py b/addons/hr_payroll/report/report_contribution_register.py
index bd9e00d3832..e32e93532b5 100644
--- a/addons/hr_payroll/report/report_contribution_register.py
+++ b/addons/hr_payroll/report/report_contribution_register.py
@@ -54,6 +54,7 @@ class contribution_register_report(report_sxw.rml_parse):
"LEFT JOIN hr_payslip AS hp on (pl.slip_id = hp.id) "\
"WHERE (hp.date_from >= %s) AND (hp.date_to <= %s) "\
"AND pl.register_id = %s "\
+ "AND hp.state = 'done' "\
"ORDER BY pl.slip_id, pl.sequence",
(self.date_from, self.date_to, obj.id))
payslip_lines = [x[0] for x in self.cr.fetchall()]
diff --git a/addons/hr_payroll/report/report_contribution_register.rml b/addons/hr_payroll/report/report_contribution_register.rml
index fedacc8786e..efe2955b22d 100644
--- a/addons/hr_payroll/report/report_contribution_register.rml
+++ b/addons/hr_payroll/report/report_contribution_register.rml
@@ -222,7 +222,7 @@
Total:
- [[ formatLang(abs(sum_total())) ]] [[o.company_id and o.company_id.currency_id.symbol or '']]
+ [[ formatLang(sum_total()) ]] [[o.company_id and o.company_id.currency_id.symbol or '']]
|
diff --git a/addons/hr_payroll_account/hr_payroll_account.py b/addons/hr_payroll_account/hr_payroll_account.py
index a58aed22730..476196759b2 100644
--- a/addons/hr_payroll_account/hr_payroll_account.py
+++ b/addons/hr_payroll_account/hr_payroll_account.py
@@ -27,17 +27,6 @@ from osv import fields, osv
from tools import config
from tools.translate import _
-
-class contrib_register(osv.osv):
- _inherit = 'hr.contribution.register'
- _description = 'Contribution Register'
-
- _columns = {
- 'account_id': fields.many2one('account.account', 'Account'),
- 'analytic_account_id':fields.many2one('account.analytic.account', 'Analytic Account'),
- }
-contrib_register()
-
#class account_move_line(osv.osv):
#
# _inherit = 'account.move.line'
@@ -84,14 +73,13 @@ class hr_payslip(osv.osv):
#TODO: to correct
def process_sheet(self, cr, uid, ids, context=None):
move_pool = self.pool.get('account.move')
- movel_pool = self.pool.get('account.move.line')
- invoice_pool = self.pool.get('account.invoice')
period_pool = self.pool.get('account.period')
timenow = time.strftime('%Y-%m-%d')
for slip in self.browse(cr, uid, ids, context=context):
line_ids = []
-
+ debit_sum = 0.0
+ credit_sum = 0.0
if not slip.period_id:
search_periods = period_pool.search(cr, uid, [('date_start','<=',slip.date_from),('date_stop','>=',slip.date_to)], context=context)
if not search_periods:
@@ -102,50 +90,74 @@ class hr_payslip(osv.osv):
name = _('Payslip of %s') % (slip.employee_id.name)
move = {
+ 'narration': name,
+ 'date': timenow,
+ 'ref': slip.number,
'journal_id': slip.journal_id.id,
'period_id': period_id,
- 'date': timenow,
- 'ref':slip.number,
- 'narration': name
}
for line in slip.line_ids:
- if line.salary_rule_id.accounting_select != 'none':
- amt = slip.credit_note and -line.total or line.total
- partner_id = False
- name = line.name
- debit_account_id = line.salary_rule_id.account_debit.id
- credit_account_id = line.salary_rule_id.account_credit.id
- if line.salary_rule_id.accounting_select == 'third_party':
- if line.salary_rule_id.register_id:
- credit_account_id = line.salary_rule_id.register_id.account_id.id
- else:
- partner_id = slip.employee_id.partner_id.id
- debit_line = (0,0,{
- 'name': line.name,
- 'account_id': debit_account_id,
- 'debit': amt > 0.0 and amt or 0.0,
- 'credit': amt < 0.0 and -amt or 0.0,
- 'date': timenow,
- 'journal_id': slip.journal_id.id,
- 'period_id': period_id,
- })
- credit_line = (0,0,{
- 'date': timenow,
- 'journal_id': slip.journal_id.id,
- 'period_id': period_id,
- 'name': name,
- 'partner_id': partner_id,
- 'account_id': credit_account_id,
- 'debit': amt < 0.0 and -amt or 0.0,
- 'credit': amt > 0.0 and amt or 0.0,
- })
- if debit_account_id:
- line_ids.append(debit_line)
- if credit_account_id:
- line_ids.append(credit_line)
+ amt = slip.credit_note and -line.total or line.total
+ partner_id = False
+ debit_account_id = line.salary_rule_id.account_debit.id
+ credit_account_id = line.salary_rule_id.account_credit.id
+ debit_line = (0, 0, {
+ 'name': line.name,
+ 'date': timenow,
+ 'partner_id': partner_id,
+ 'account_id': debit_account_id,
+ 'journal_id': slip.journal_id.id,
+ 'period_id': period_id,
+ 'debit': amt > 0.0 and amt or 0.0,
+ 'credit': amt < 0.0 and -amt or 0.0,
+ })
+ credit_line = (0, 0, {
+ 'name': line.name,
+ 'date': timenow,
+ 'partner_id': partner_id,
+ 'account_id': credit_account_id,
+ 'journal_id': slip.journal_id.id,
+ 'period_id': period_id,
+ 'debit': amt < 0.0 and -amt or 0.0,
+ 'credit': amt > 0.0 and amt or 0.0,
+ })
+ if debit_account_id:
+ line_ids.append(debit_line)
+ debit_sum += debit_line[2]['debit']
+ if credit_account_id:
+ line_ids.append(credit_line)
+ credit_sum += credit_line[2]['credit']
+
+ if debit_sum > credit_sum:
+ adjust_credit = (0, 0, {
+ 'name': _('Adjustment Entry'),
+ 'date': timenow,
+ 'partner_id': partner_id,
+ 'account_id': slip.journal_id.default_credit_account_id.id,
+ 'journal_id': slip.journal_id.id,
+ 'period_id': period_id,
+ 'debit': 0.0,
+ 'credit': debit_sum - credit_sum,
+ })
+ line_ids.append(adjust_credit)
+ elif debit_sum < credit_sum:
+ adjust_debit = (0, 0, {
+ 'name': _('Adjustment Entry'),
+ 'date': timenow,
+ 'partner_id': partner_id,
+ 'account_id': slip.journal_id.default_debit_account_id.id,
+ 'journal_id': slip.journal_id.id,
+ 'period_id': period_id,
+ 'debit': credit_sum - debit_sum,
+ 'credit': 0.0
+ })
+ line_ids.append(adjust_debit)
+
move.update({'line_id': line_ids})
move_id = move_pool.create(cr, uid, move, context=context)
self.write(cr, uid, [slip.id], {'move_id': move_id}, context=context)
+ if slip.journal_id.entry_posted:
+ move_pool.post(cr, uid, [move_id], context=context)
return super(hr_payslip, self).process_sheet(cr, uid, [slip.id], context=context)
#TODO: to clean: the verofying doesn't do anything in the accounting..
@@ -381,7 +393,6 @@ hr_payslip()
class hr_salary_rule(osv.osv):
_inherit = 'hr.salary.rule'
_columns = {
- 'accounting_select':fields.selection([('none', 'No Accounting Entries'), ('third_party', 'To Employee or contribution Register'), ('yes','Regular Entries')], 'Accounting Entries Option'),
'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'),
diff --git a/addons/hr_payroll_account/hr_payroll_account_view.xml b/addons/hr_payroll_account/hr_payroll_account_view.xml
index 4b36508138d..825fac9cab4 100644
--- a/addons/hr_payroll_account/hr_payroll_account_view.xml
+++ b/addons/hr_payroll_account/hr_payroll_account_view.xml
@@ -18,20 +18,6 @@
-
- hr.contribution.register.inherit.form
- hr.contribution.register
-
- form
-
-
-
-
-
-
-
-
-
@@ -41,11 +27,10 @@
-
-
-
-
-
+
+
+
+
@@ -59,11 +44,11 @@
form
-
-
-
-
-
+
+
+
+
+