Merge lp:~openbig/bigconsulting/wizard_open_lines into lp:bigconsulting
- wizard_open_lines
- Merge into addons
Proposed by
gpa(OpenERP)
Status: | Merged |
---|---|
Merged at revision: | 93 |
Proposed branch: | lp:~openbig/bigconsulting/wizard_open_lines |
Merge into: | lp:bigconsulting |
Diff against target: |
320 lines (+206/-20) 5 files modified
account_invoice_cash_discount/account_invoice_cash_discount_wizard.xml (+13/-0) account_invoice_cash_discount/wizard/__init__.py (+1/-0) account_invoice_cash_discount/wizard/invoice_statement_payment.py (+23/-18) account_invoice_cash_discount/wizard/wizard_write_period_entry_calculation.py (+169/-0) account_payment_discount_extension/account_payment_discount.py (+0/-2) |
To merge this branch: | bzr merge lp:~openbig/bigconsulting/wizard_open_lines |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
openbig | Pending | ||
Review via email: mp+35662@code.launchpad.net |
Commit message
Description of the change
improvement to open the computed lines
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'account_invoice_cash_discount/account_invoice_cash_discount_wizard.xml' | |||
2 | --- account_invoice_cash_discount/account_invoice_cash_discount_wizard.xml 2010-09-13 09:11:53 +0000 | |||
3 | +++ account_invoice_cash_discount/account_invoice_cash_discount_wizard.xml 2010-09-16 13:35:58 +0000 | |||
4 | @@ -14,5 +14,18 @@ | |||
5 | 14 | name="account.move.line.discount.reconcile" | 14 | name="account.move.line.discount.reconcile" |
6 | 15 | menu="True" | 15 | menu="True" |
7 | 16 | id="account.wizard_reconcile"/> | 16 | id="account.wizard_reconcile"/> |
8 | 17 | <wizard | ||
9 | 18 | string="Compute Period Wise Write-off Entry" | ||
10 | 19 | model="account.move.line" | ||
11 | 20 | name="account_period_write_calculation" | ||
12 | 21 | menu="True" | ||
13 | 22 | id="wizard_period_writeoff_calculation"/> | ||
14 | 23 | |||
15 | 24 | <menuitem | ||
16 | 25 | action="wizard_period_writeoff_calculation" | ||
17 | 26 | id="menu_period_writeoff_calculation" | ||
18 | 27 | parent="account.menu_finance" | ||
19 | 28 | type="wizard"/> | ||
20 | 29 | |||
21 | 17 | </data> | 30 | </data> |
22 | 18 | </openerp> | 31 | </openerp> |
23 | 19 | 32 | ||
24 | === modified file 'account_invoice_cash_discount/wizard/__init__.py' | |||
25 | --- account_invoice_cash_discount/wizard/__init__.py 2010-09-13 09:11:53 +0000 | |||
26 | +++ account_invoice_cash_discount/wizard/__init__.py 2010-09-16 13:35:58 +0000 | |||
27 | @@ -23,6 +23,7 @@ | |||
28 | 23 | import account_pay_invoice | 23 | import account_pay_invoice |
29 | 24 | import invoice_statement_payment | 24 | import invoice_statement_payment |
30 | 25 | import wizard_discount_reconcile | 25 | import wizard_discount_reconcile |
31 | 26 | import wizard_write_period_entry_calculation | ||
32 | 26 | 27 | ||
33 | 27 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | 28 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
34 | 28 | 29 | ||
35 | 29 | 30 | ||
36 | === modified file 'account_invoice_cash_discount/wizard/invoice_statement_payment.py' | |||
37 | --- account_invoice_cash_discount/wizard/invoice_statement_payment.py 2010-08-06 12:28:07 +0000 | |||
38 | +++ account_invoice_cash_discount/wizard/invoice_statement_payment.py 2010-09-16 13:35:58 +0000 | |||
39 | @@ -125,29 +125,28 @@ | |||
40 | 125 | # ctx['date'] = line.date_maturity | 125 | # ctx['date'] = line.date_maturity |
41 | 126 | # else: | 126 | # else: |
42 | 127 | ctx['date'] = line_date | 127 | ctx['date'] = line_date |
52 | 128 | amount = 0.0 | 128 | invoice_amount = 0.0 |
53 | 129 | if line.amount_currency: | 129 | |
54 | 130 | amount = currency_obj.compute(cursor, user, line.currency_id.id, | 130 | if line.debit > 0: |
55 | 131 | statement.currency.id, line.amount_currency, context=ctx) | 131 | invoice_amount = line.debit |
56 | 132 | else: | 132 | elif line.credit > 0: |
57 | 133 | if line.debit > 0: | 133 | invoice_amount = -line.credit |
58 | 134 | amount=line.debit | 134 | |
59 | 135 | elif line.credit > 0: | 135 | |
51 | 136 | amount=-line.credit | ||
60 | 137 | reconcile_id = statement_reconcile_obj.create(cursor, user, { | 136 | reconcile_id = statement_reconcile_obj.create(cursor, user, { |
61 | 138 | 'line_ids': [(6, 0, [line.id])] | 137 | 'line_ids': [(6, 0, [line.id])] |
62 | 139 | }, context=context) | 138 | }, context=context) |
63 | 140 | 139 | ||
64 | 141 | ######################################### Calculation for discount and taxes###### | 140 | ######################################### Calculation for discount and taxes###### |
65 | 142 | if line.invoice.id: | 141 | if line.invoice.id: |
66 | 143 | |||
67 | 144 | discount = 0.0 | 142 | discount = 0.0 |
68 | 145 | account = False | 143 | account = False |
69 | 146 | invoice = obj_inv.browse(cursor, user, line.invoice.id, context=context) | 144 | invoice = obj_inv.browse(cursor, user, line.invoice.id, context=context) |
70 | 147 | for invoice_line in invoice.invoice_line: | 145 | for invoice_line in invoice.invoice_line: |
71 | 148 | line_tax_amount = 0.0 | 146 | line_tax_amount = 0.0 |
72 | 149 | invoice_amount = 0.0 | ||
73 | 150 | total_tax_amount = 0.0 | 147 | total_tax_amount = 0.0 |
74 | 148 | inv_dis_amount = 0.0 | ||
75 | 149 | cal_invoice_amount = 0.0 | ||
76 | 151 | tax_account_id = False | 150 | tax_account_id = False |
77 | 152 | tax_code_id = False | 151 | tax_code_id = False |
78 | 153 | tax_base_id = False | 152 | tax_base_id = False |
79 | @@ -158,10 +157,15 @@ | |||
80 | 158 | invoice_res_amount = invoice.amount_total | 157 | invoice_res_amount = invoice.amount_total |
81 | 159 | line_ratio = line_total / invoice_res_amount | 158 | line_ratio = line_total / invoice_res_amount |
82 | 160 | ########################### | 159 | ########################### |
87 | 161 | amount = obj_inv._get_amount(cursor, user, [invoice.id] ,invoice.residual, invoice.payment_term.id, context=context) | 160 | if line.amount_currency: |
88 | 162 | invoice_amount = amount['amount'] | 161 | inv_dis_amount = currency_obj.compute(cursor, user, line.currency_id.id, statement.currency.id, line.amount_currency, context=ctx) |
89 | 163 | discount = obj_inv._get_payment(cursor, user, [invoice.id] , invoice_amount, invoice.payment_term.id, context=context) | 162 | elif (line.invoice and line.invoice.currency_id.id <> statement.currency.id): |
90 | 164 | account = obj_inv._get_account(cursor, user, [invoice.id] , invoice.residual, invoice.payment_term.id, context=context) | 163 | inv_dis_amount = currency_obj.compute(cursor, user, line.invoice.currency_id.id,statement.currency.id, invoice_amount, context=ctx) |
91 | 164 | |||
92 | 165 | amount = obj_inv._get_amount(cursor, user, [invoice.id] , inv_dis_amount, invoice.payment_term.id, context=context) | ||
93 | 166 | cal_invoice_amount = amount['amount'] | ||
94 | 167 | discount = obj_inv._get_payment(cursor, user, [invoice.id], cal_invoice_amount, invoice.payment_term.id, context=context) | ||
95 | 168 | account = obj_inv._get_account(cursor, user, [invoice.id], cal_invoice_amount, invoice.payment_term.id, context=context) | ||
96 | 165 | 169 | ||
97 | 166 | ### discount for the invoice line | 170 | ### discount for the invoice line |
98 | 167 | discount_pay = discount * line_ratio | 171 | discount_pay = discount * line_ratio |
99 | @@ -183,7 +187,7 @@ | |||
100 | 183 | tax_code_id = tax_value.tax_code_id.id | 187 | tax_code_id = tax_value.tax_code_id.id |
101 | 184 | tax_base_id = tax_value.base_code_id.id | 188 | tax_base_id = tax_value.base_code_id.id |
102 | 185 | 189 | ||
104 | 186 | if tax_real_amt>0: | 190 | if tax_real_amt: |
105 | 187 | statement_reconcile_line_obj.create(cursor, user, { | 191 | statement_reconcile_line_obj.create(cursor, user, { |
106 | 188 | 'name': line.name, | 192 | 'name': line.name, |
107 | 189 | 'amount': tax_real_amt, | 193 | 'amount': tax_real_amt, |
108 | @@ -191,7 +195,8 @@ | |||
109 | 191 | 'line_id': reconcile_id, | 195 | 'line_id': reconcile_id, |
110 | 192 | 'tax_code_id':tax_code_id | 196 | 'tax_code_id':tax_code_id |
111 | 193 | }, context=context) | 197 | }, context=context) |
113 | 194 | if discount>0: | 198 | |
114 | 199 | if discount: | ||
115 | 195 | discount = discount * line_ratio | 200 | discount = discount * line_ratio |
116 | 196 | statement_reconcile_line_obj.create(cursor, user, { | 201 | statement_reconcile_line_obj.create(cursor, user, { |
117 | 197 | 'name': line.name, | 202 | 'name': line.name, |
118 | @@ -211,7 +216,7 @@ | |||
119 | 211 | 216 | ||
120 | 212 | statement_line_obj.create(cursor, user, { | 217 | statement_line_obj.create(cursor, user, { |
121 | 213 | 'name': line.name or '?', | 218 | 'name': line.name or '?', |
123 | 214 | 'amount': invoice_amount, | 219 | 'amount': cal_invoice_amount, |
124 | 215 | 'type': type, | 220 | 'type': type, |
125 | 216 | 'partner_id': line.partner_id.id, | 221 | 'partner_id': line.partner_id.id, |
126 | 217 | 'account_id': line.account_id.id, | 222 | 'account_id': line.account_id.id, |
127 | 218 | 223 | ||
128 | === added file 'account_invoice_cash_discount/wizard/wizard_write_period_entry_calculation.py' | |||
129 | --- account_invoice_cash_discount/wizard/wizard_write_period_entry_calculation.py 1970-01-01 00:00:00 +0000 | |||
130 | +++ account_invoice_cash_discount/wizard/wizard_write_period_entry_calculation.py 2010-09-16 13:35:58 +0000 | |||
131 | @@ -0,0 +1,169 @@ | |||
132 | 1 | # -*- encoding: utf-8 -*- | ||
133 | 2 | ############################################################################## | ||
134 | 3 | # | ||
135 | 4 | # OpenERP, Open Source Management Solution | ||
136 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved | ||
137 | 6 | # $Id$ | ||
138 | 7 | # | ||
139 | 8 | # This program is free software: you can redistribute it and/or modify | ||
140 | 9 | # it under the terms of the GNU General Public License as published by | ||
141 | 10 | # the Free Software Foundation, either version 3 of the License, or | ||
142 | 11 | # (at your option) any later version. | ||
143 | 12 | # | ||
144 | 13 | # This program is distributed in the hope that it will be useful, | ||
145 | 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
146 | 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
147 | 16 | # GNU General Public License for more details. | ||
148 | 17 | # | ||
149 | 18 | # You should have received a copy of the GNU General Public License | ||
150 | 19 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
151 | 20 | # | ||
152 | 21 | ############################################################################## | ||
153 | 22 | |||
154 | 23 | import wizard | ||
155 | 24 | import pooler | ||
156 | 25 | import time | ||
157 | 26 | from datetime import datetime | ||
158 | 27 | from dateutil.relativedelta import relativedelta | ||
159 | 28 | from mx import DateTime | ||
160 | 29 | from tools.translate import _ | ||
161 | 30 | |||
162 | 31 | _writeoff_entry_calculation_form = '''<?xml version="1.0"?> | ||
163 | 32 | <form string="Calculation"> | ||
164 | 33 | <separator string="Calculation of period wise Write off Amount" colspan="4"/> | ||
165 | 34 | <field name="cash_discount_id"/> | ||
166 | 35 | <field name="tax_id"/> | ||
167 | 36 | <field name="period_id"/> | ||
168 | 37 | <field name="journal_id"/> | ||
169 | 38 | </form>''' | ||
170 | 39 | |||
171 | 40 | _writeoff_entry_calculation_fields = { | ||
172 | 41 | 'cash_discount_id': {'string':'Cash Discount Account', 'type':'many2one', 'relation':'account.account', 'required':True}, | ||
173 | 42 | 'tax_id': {'string':'Taxes', 'type':'many2one', 'relation':'account.tax', 'required':True}, | ||
174 | 43 | 'period_id': {'string':'Period', 'type':'many2one', 'relation':'account.period', 'required':True}, | ||
175 | 44 | 'journal_id': {'string':'Journal', 'type':'many2one', 'relation':'account.journal', 'required':True}, | ||
176 | 45 | |||
177 | 46 | } | ||
178 | 47 | |||
179 | 48 | def _compute(self, cr, uid, data, context): | ||
180 | 49 | |||
181 | 50 | pool = pooler.get_pool(cr.dbname) | ||
182 | 51 | payment_term_obj = pool.get('account.payment.term') | ||
183 | 52 | invoice_obj = pool.get('account.invoice') | ||
184 | 53 | account_move_line_obj = pool.get('account.move.line') | ||
185 | 54 | tax_obj = pool.get('account.tax') | ||
186 | 55 | account_move_obj= pool.get('account.move') | ||
187 | 56 | |||
188 | 57 | period_id = data['form']['period_id'] | ||
189 | 58 | tax_id = data['form']['tax_id'] | ||
190 | 59 | journal_id = data['form']['journal_id'] | ||
191 | 60 | cash_discount_id = data['form']['cash_discount_id'] | ||
192 | 61 | |||
193 | 62 | account_move_line_ids = account_move_line_obj.search(cr, uid, [('period_id','=',period_id),('account_id','=',cash_discount_id)]) | ||
194 | 63 | date = time.strftime('%Y-%m-%d') | ||
195 | 64 | |||
196 | 65 | discount_lines = [] | ||
197 | 66 | |||
198 | 67 | tax_account_id = False | ||
199 | 68 | dis_tax_code_id = False | ||
200 | 69 | discount_code_id = False | ||
201 | 70 | |||
202 | 71 | for line in account_move_line_obj.browse(cr, uid, account_move_line_ids, context=context): | ||
203 | 72 | tax_discount_amt = 0.0 | ||
204 | 73 | tax_discount_data = tax_obj.browse(cr, uid, tax_id, context=context) | ||
205 | 74 | if tax_discount_data.account_collected_id: | ||
206 | 75 | tax_account_id = tax_discount_data.account_collected_id.id | ||
207 | 76 | else: | ||
208 | 77 | tax_account_id = tax_discount_data.tax_code_id.id | ||
209 | 78 | |||
210 | 79 | discount_code_id = tax_discount_data.base_code_id.id | ||
211 | 80 | dis_tax_code_id = tax_discount_data.tax_code_id.id | ||
212 | 81 | |||
213 | 82 | if line.debit>0.0: | ||
214 | 83 | tax_discount_amt = 0.0 | ||
215 | 84 | tax_discount_amt = line.debit * tax_discount_data.amount | ||
216 | 85 | |||
217 | 86 | discount_lines.append( | ||
218 | 87 | (0, 0, { | ||
219 | 88 | 'name':line.name, | ||
220 | 89 | 'debit':tax_discount_amt, | ||
221 | 90 | 'credit':0.0, | ||
222 | 91 | 'account_id':cash_discount_id, | ||
223 | 92 | 'date':date, | ||
224 | 93 | 'partner_id':line.partner_id.id, | ||
225 | 94 | 'tax_amount':-tax_discount_amt, | ||
226 | 95 | 'tax_code_id':discount_code_id, | ||
227 | 96 | })), | ||
228 | 97 | |||
229 | 98 | discount_lines.append( | ||
230 | 99 | (0, 0, { | ||
231 | 100 | 'name':line.name, | ||
232 | 101 | 'debit':0.0, | ||
233 | 102 | 'credit':tax_discount_amt, | ||
234 | 103 | 'account_id':tax_account_id, | ||
235 | 104 | 'date':date, | ||
236 | 105 | 'partner_id':line.partner_id.id, | ||
237 | 106 | 'tax_amount':-tax_discount_amt, | ||
238 | 107 | 'tax_code_id':dis_tax_code_id, | ||
239 | 108 | })) | ||
240 | 109 | |||
241 | 110 | elif line.credit>0.0: | ||
242 | 111 | tax_discount_amt = 0.0 | ||
243 | 112 | tax_discount_amt = line.credit * tax_discount_data.amount | ||
244 | 113 | |||
245 | 114 | discount_lines.append( | ||
246 | 115 | (0, 0, { | ||
247 | 116 | 'name':line.name, | ||
248 | 117 | 'debit':tax_discount_amt, | ||
249 | 118 | 'credit':0.0, | ||
250 | 119 | 'account_id':tax_account_id, | ||
251 | 120 | 'date':date, | ||
252 | 121 | 'partner_id':line.partner_id.id, | ||
253 | 122 | 'tax_amount':-tax_discount_amt, | ||
254 | 123 | 'tax_code_id':dis_tax_code_id, | ||
255 | 124 | })) | ||
256 | 125 | |||
257 | 126 | discount_lines.append( | ||
258 | 127 | (0, 0, { | ||
259 | 128 | 'name':line.name, | ||
260 | 129 | 'debit':0.0, | ||
261 | 130 | 'credit':tax_discount_amt, | ||
262 | 131 | 'account_id':cash_discount_id, | ||
263 | 132 | 'date':date, | ||
264 | 133 | 'partner_id':line.partner_id.id, | ||
265 | 134 | 'tax_amount':-tax_discount_amt, | ||
266 | 135 | 'tax_code_id':discount_code_id, | ||
267 | 136 | })), | ||
268 | 137 | |||
269 | 138 | discount_move_line = account_move_obj.create(cr, uid, | ||
270 | 139 | { | ||
271 | 140 | 'period_id': period_id, | ||
272 | 141 | 'journal_id': journal_id, | ||
273 | 142 | 'date':date, | ||
274 | 143 | 'line_id': discount_lines | ||
275 | 144 | }) | ||
276 | 145 | |||
277 | 146 | return { | ||
278 | 147 | 'domain': [('id','=',discount_move_line)], | ||
279 | 148 | 'name': _('Computed Entries'), | ||
280 | 149 | 'view_type': 'form', | ||
281 | 150 | 'view_mode': 'tree,form', | ||
282 | 151 | 'view_id': False, | ||
283 | 152 | 'res_model': 'account.move', | ||
284 | 153 | 'type': 'ir.actions.act_window' | ||
285 | 154 | } | ||
286 | 155 | |||
287 | 156 | class wiz_period_writeoff_calculation(wizard.interface): | ||
288 | 157 | states = { | ||
289 | 158 | 'init': { | ||
290 | 159 | 'actions': [], | ||
291 | 160 | 'result': {'type': 'form', 'arch':_writeoff_entry_calculation_form, 'fields':_writeoff_entry_calculation_fields, 'state':[('calculate','Compute'),('end','Cancel')]} | ||
292 | 161 | }, | ||
293 | 162 | 'calculate': { | ||
294 | 163 | 'actions': [], | ||
295 | 164 | 'result': {'type': 'action', 'action': _compute, 'state':'end'} | ||
296 | 165 | } | ||
297 | 166 | } | ||
298 | 167 | wiz_period_writeoff_calculation('account_period_write_calculation') | ||
299 | 168 | |||
300 | 169 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
301 | 0 | 170 | ||
302 | === modified file 'account_payment_discount_extension/account_payment_discount.py' | |||
303 | --- account_payment_discount_extension/account_payment_discount.py 2010-09-16 09:39:50 +0000 | |||
304 | +++ account_payment_discount_extension/account_payment_discount.py 2010-09-16 13:35:58 +0000 | |||
305 | @@ -102,7 +102,6 @@ | |||
306 | 102 | string="Customer Cash Discount Account", | 102 | string="Customer Cash Discount Account", |
307 | 103 | method=True, | 103 | method=True, |
308 | 104 | view_load=True, | 104 | view_load=True, |
309 | 105 | domain="[('type', '=', 'receivable')]", | ||
310 | 106 | required=True), | 105 | required=True), |
311 | 107 | 'property_supplier_cash_discount_account': fields.property( | 106 | 'property_supplier_cash_discount_account': fields.property( |
312 | 108 | 'account.account', | 107 | 'account.account', |
313 | @@ -111,7 +110,6 @@ | |||
314 | 111 | string="Supplier Cash Discount Account", | 110 | string="Supplier Cash Discount Account", |
315 | 112 | method=True, | 111 | method=True, |
316 | 113 | view_load=True, | 112 | view_load=True, |
317 | 114 | domain="[('type', '=', 'payable')]", | ||
318 | 115 | required=True), | 113 | required=True), |
319 | 116 | } | 114 | } |
320 | 117 | res_partner() | 115 | res_partner() |