Merge lp:~serpent-consulting-services/openobject-addons/trunk-885663-SerpentCS into lp:openobject-addons

Proposed by Serpent Consulting Services
Status: Merged
Merged at revision: 5627
Proposed branch: lp:~serpent-consulting-services/openobject-addons/trunk-885663-SerpentCS
Merge into: lp:openobject-addons
Diff against target: 77 lines (+19/-9)
1 file modified
hr_payroll_account/hr_payroll_account.py (+19/-9)
To merge this branch: bzr merge lp:~serpent-consulting-services/openobject-addons/trunk-885663-SerpentCS
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+81246@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Serpent Consulting Services (serpent-consulting-services) wrote :

The merge contains optimization changes as well.
Thanks.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'hr_payroll_account/hr_payroll_account.py'
--- hr_payroll_account/hr_payroll_account.py 2011-10-11 14:03:35 +0000
+++ hr_payroll_account/hr_payroll_account.py 2011-11-04 08:38:28 +0000
@@ -95,7 +95,10 @@
95 partner_id = False95 partner_id = False
96 debit_account_id = line.salary_rule_id.account_debit.id96 debit_account_id = line.salary_rule_id.account_debit.id
97 credit_account_id = line.salary_rule_id.account_credit.id97 credit_account_id = line.salary_rule_id.account_credit.id
98 debit_line = (0, 0, {98
99 if debit_account_id:
100
101 debit_line = (0, 0, {
99 'name': line.name,102 'name': line.name,
100 'date': timenow,103 'date': timenow,
101 'partner_id': partner_id,104 'partner_id': partner_id,
@@ -108,7 +111,12 @@
108 'tax_code_id': line.salary_rule_id.account_tax_id and line.salary_rule_id.account_tax_id.id or False,111 'tax_code_id': line.salary_rule_id.account_tax_id and line.salary_rule_id.account_tax_id.id or False,
109 'tax_amount': line.salary_rule_id.account_tax_id and amt or 0.0,112 'tax_amount': line.salary_rule_id.account_tax_id and amt or 0.0,
110 })113 })
111 credit_line = (0, 0, {114 line_ids.append(debit_line)
115 debit_sum += debit_line[2]['debit'] - debit_line[2]['credit']
116
117 if credit_account_id:
118
119 credit_line = (0, 0, {
112 'name': line.name,120 'name': line.name,
113 'date': timenow,121 'date': timenow,
114 'partner_id': partner_id,122 'partner_id': partner_id,
@@ -121,38 +129,40 @@
121 'tax_code_id': line.salary_rule_id.account_tax_id and line.salary_rule_id.account_tax_id.id or False,129 'tax_code_id': line.salary_rule_id.account_tax_id and line.salary_rule_id.account_tax_id.id or False,
122 'tax_amount': line.salary_rule_id.account_tax_id and amt or 0.0,130 'tax_amount': line.salary_rule_id.account_tax_id and amt or 0.0,
123 })131 })
124 if debit_account_id:
125 line_ids.append(debit_line)
126 debit_sum += debit_line[2]['debit'] - debit_line[2]['credit']
127 if credit_account_id:
128 line_ids.append(credit_line)132 line_ids.append(credit_line)
129 credit_sum += credit_line[2]['credit'] - credit_line[2]['debit']133 credit_sum += credit_line[2]['credit'] - credit_line[2]['debit']
130134
131 if debit_sum > credit_sum:135 if debit_sum > credit_sum:
136 acc_id = slip.journal_id.default_credit_account_id.id
137 if not acc_id:
138 raise osv.except_osv(_('Configuration Error!'),_('The Expense Journal "%s" has not properly configured the Credit Account!')%(slip.journal_id.name))
132 adjust_credit = (0, 0, {139 adjust_credit = (0, 0, {
133 'name': _('Adjustment Entry'),140 'name': _('Adjustment Entry'),
134 'date': timenow,141 'date': timenow,
135 'partner_id': partner_id,142 'partner_id': partner_id,
136 'account_id': slip.journal_id.default_credit_account_id.id,143 'account_id': acc_id,
137 'journal_id': slip.journal_id.id,144 'journal_id': slip.journal_id.id,
138 'period_id': period_id,145 'period_id': period_id,
139 'debit': 0.0,146 'debit': 0.0,
140 'credit': debit_sum - credit_sum,147 'credit': debit_sum - credit_sum,
141 })148 })
142 line_ids.append(adjust_credit)149 line_ids.append(adjust_credit)
150
143 elif debit_sum < credit_sum:151 elif debit_sum < credit_sum:
152 acc_id = slip.journal_id.default_debit_account_id.id
153 if not acc_id:
154 raise osv.except_osv(_('Configuration Error!'),_('The Expense Journal "%s" has not properly configured the Debit Account!')%(slip.journal_id.name))
144 adjust_debit = (0, 0, {155 adjust_debit = (0, 0, {
145 'name': _('Adjustment Entry'),156 'name': _('Adjustment Entry'),
146 'date': timenow,157 'date': timenow,
147 'partner_id': partner_id,158 'partner_id': partner_id,
148 'account_id': slip.journal_id.default_debit_account_id.id,159 'account_id': acc_id,
149 'journal_id': slip.journal_id.id,160 'journal_id': slip.journal_id.id,
150 'period_id': period_id,161 'period_id': period_id,
151 'debit': credit_sum - debit_sum,162 'debit': credit_sum - debit_sum,
152 'credit': 0.0,163 'credit': 0.0,
153 })164 })
154 line_ids.append(adjust_debit)165 line_ids.append(adjust_debit)
155
156 move.update({'line_id': line_ids})166 move.update({'line_id': line_ids})
157 move_id = move_pool.create(cr, uid, move, context=context)167 move_id = move_pool.create(cr, uid, move, context=context)
158 self.write(cr, uid, [slip.id], {'move_id': move_id}, context=context)168 self.write(cr, uid, [slip.id], {'move_id': move_id}, context=context)

Subscribers

People subscribed via source and target branches

to all changes: