Merge lp:~openbig/bigconsulting/compute_wizard into lp:bigconsulting

Proposed by gpa(OpenERP)
Status: Superseded
Proposed branch: lp:~openbig/bigconsulting/compute_wizard
Merge into: lp:bigconsulting
Diff against target: 219 lines (+174/-2)
4 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/wizard_write_period_entry_calculation.py (+160/-0)
account_payment_discount_extension/account_payment_discount.py (+0/-2)
To merge this branch: bzr merge lp:~openbig/bigconsulting/compute_wizard
Reviewer Review Type Date Requested Status
openbig Pending
Review via email: mp+35642@code.launchpad.net

This proposal supersedes a proposal from 2010-09-16.

This proposal has been superseded by a proposal from 2010-09-16.

Description of the change

added wizard

To post a comment you must log in.

Unmerged revisions

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 10:39:51 +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 10:39:51 +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=== added file 'account_invoice_cash_discount/wizard/wizard_write_period_entry_calculation.py'
37--- account_invoice_cash_discount/wizard/wizard_write_period_entry_calculation.py 1970-01-01 00:00:00 +0000
38+++ account_invoice_cash_discount/wizard/wizard_write_period_entry_calculation.py 2010-09-16 10:39:51 +0000
39@@ -0,0 +1,160 @@
40+# -*- encoding: utf-8 -*-
41+##############################################################################
42+#
43+# OpenERP, Open Source Management Solution
44+# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
45+# $Id$
46+#
47+# This program is free software: you can redistribute it and/or modify
48+# it under the terms of the GNU General Public License as published by
49+# the Free Software Foundation, either version 3 of the License, or
50+# (at your option) any later version.
51+#
52+# This program is distributed in the hope that it will be useful,
53+# but WITHOUT ANY WARRANTY; without even the implied warranty of
54+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
55+# GNU General Public License for more details.
56+#
57+# You should have received a copy of the GNU General Public License
58+# along with this program. If not, see <http://www.gnu.org/licenses/>.
59+#
60+##############################################################################
61+
62+import wizard
63+import pooler
64+import time
65+from datetime import datetime
66+from dateutil.relativedelta import relativedelta
67+from mx import DateTime
68+from tools.translate import _
69+
70+_writeoff_entry_calculation_form = '''<?xml version="1.0"?>
71+<form string="Calculation">
72+ <separator string="Calculation of period wise Write off Amount" colspan="4"/>
73+ <field name="cash_discount_id"/>
74+ <field name="tax_id"/>
75+ <field name="period_id"/>
76+ <field name="journal_id"/>
77+</form>'''
78+
79+_writeoff_entry_calculation_fields = {
80+ 'cash_discount_id': {'string':'Cash Discount Account', 'type':'many2one', 'relation':'account.account', 'required':True},
81+ 'tax_id': {'string':'Taxes', 'type':'many2one', 'relation':'account.tax', 'required':True},
82+ 'period_id': {'string':'Period', 'type':'many2one', 'relation':'account.period', 'required':True},
83+ 'journal_id': {'string':'Journal', 'type':'many2one', 'relation':'account.journal', 'required':True},
84+
85+}
86+
87+def _compute(self, cr, uid, data, context):
88+
89+ pool = pooler.get_pool(cr.dbname)
90+ payment_term_obj = pool.get('account.payment.term')
91+ invoice_obj = pool.get('account.invoice')
92+ account_move_line_obj = pool.get('account.move.line')
93+ tax_obj = pool.get('account.tax')
94+ account_move_obj= pool.get('account.move')
95+
96+ period_id = data['form']['period_id']
97+ tax_id = data['form']['tax_id']
98+ journal_id = data['form']['journal_id']
99+ cash_discount_id = data['form']['cash_discount_id']
100+
101+ account_move_line_ids = account_move_line_obj.search(cr, uid, [('period_id','=',period_id),('account_id','=',cash_discount_id)])
102+ date = time.strftime('%Y-%m-%d')
103+
104+ discount_lines = []
105+
106+ tax_account_id = False
107+ dis_tax_code_id = False
108+ discount_code_id = False
109+
110+ for line in account_move_line_obj.browse(cr, uid, account_move_line_ids, context=context):
111+ tax_discount_amt = 0.0
112+ tax_discount_data = tax_obj.browse(cr, uid, tax_id, context=context)
113+ if tax_discount_data.account_collected_id:
114+ tax_account_id = tax_discount_data.account_collected_id.id
115+ else:
116+ tax_account_id = tax_discount_data.tax_code_id.id
117+
118+ discount_code_id = tax_discount_data.base_code_id.id
119+ dis_tax_code_id = tax_discount_data.tax_code_id.id
120+
121+ if line.debit>0.0:
122+ tax_discount_amt = 0.0
123+ tax_discount_amt = line.debit * tax_discount_data.amount
124+
125+ discount_lines.append(
126+ (0, 0, {
127+ 'name':line.name,
128+ 'debit':tax_discount_amt,
129+ 'credit':0.0,
130+ 'account_id':cash_discount_id,
131+ 'date':date,
132+ 'partner_id':line.partner_id.id,
133+ 'tax_amount':-tax_discount_amt,
134+ 'tax_code_id':discount_code_id,
135+ })),
136+
137+ discount_lines.append(
138+ (0, 0, {
139+ 'name':line.name,
140+ 'debit':0.0,
141+ 'credit':tax_discount_amt,
142+ 'account_id':tax_account_id,
143+ 'date':date,
144+ 'partner_id':line.partner_id.id,
145+ 'tax_amount':-tax_discount_amt,
146+ 'tax_code_id':dis_tax_code_id,
147+ }))
148+
149+ elif line.credit>0.0:
150+ tax_discount_amt = 0.0
151+ tax_discount_amt = line.credit * tax_discount_data.amount
152+
153+ discount_lines.append(
154+ (0, 0, {
155+ 'name':line.name,
156+ 'debit':tax_discount_amt,
157+ 'credit':0.0,
158+ 'account_id':tax_account_id,
159+ 'date':date,
160+ 'partner_id':line.partner_id.id,
161+ 'tax_amount':-tax_discount_amt,
162+ 'tax_code_id':dis_tax_code_id,
163+ }))
164+
165+ discount_lines.append(
166+ (0, 0, {
167+ 'name':line.name,
168+ 'debit':0.0,
169+ 'credit':tax_discount_amt,
170+ 'account_id':cash_discount_id,
171+ 'date':date,
172+ 'partner_id':line.partner_id.id,
173+ 'tax_amount':-tax_discount_amt,
174+ 'tax_code_id':discount_code_id,
175+ })),
176+
177+ account_move_obj.create(cr, uid,
178+ {
179+ 'period_id': period_id,
180+ 'journal_id': journal_id,
181+ 'date':date,
182+ 'line_id': discount_lines
183+ })
184+ return {}
185+
186+class wiz_period_writeoff_calculation(wizard.interface):
187+ states = {
188+ 'init': {
189+ 'actions': [],
190+ 'result': {'type': 'form', 'arch':_writeoff_entry_calculation_form, 'fields':_writeoff_entry_calculation_fields, 'state':[('calculate','Compute'),('end','Cancel')]}
191+ },
192+ 'calculate': {
193+ 'actions': [],
194+ 'result': {'type': 'action', 'action': _compute, 'state':'end'}
195+ }
196+ }
197+wiz_period_writeoff_calculation('account_period_write_calculation')
198+
199+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
200
201=== modified file 'account_payment_discount_extension/account_payment_discount.py'
202--- account_payment_discount_extension/account_payment_discount.py 2010-09-16 09:39:50 +0000
203+++ account_payment_discount_extension/account_payment_discount.py 2010-09-16 10:39:51 +0000
204@@ -102,7 +102,6 @@
205 string="Customer Cash Discount Account",
206 method=True,
207 view_load=True,
208- domain="[('type', '=', 'receivable')]",
209 required=True),
210 'property_supplier_cash_discount_account': fields.property(
211 'account.account',
212@@ -111,7 +110,6 @@
213 string="Supplier Cash Discount Account",
214 method=True,
215 view_load=True,
216- domain="[('type', '=', 'payable')]",
217 required=True),
218 }
219 res_partner()

Subscribers

People subscribed via source and target branches