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