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: 207 lines (+162/-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 (+148/-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+35641@code.launchpad.net

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:06:47 +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:06:47 +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:06:47 +0000
39@@ -0,0 +1,148 @@
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+ tax_account_id = False
106+
107+ for line in account_move_line_obj.browse(cr, uid, account_move_line_ids, context=context):
108+ tax_discount_amt = 0.0
109+ tax_discount_data = tax_obj.browse(cr, uid, tax_id, context=context)
110+ if tax_discount_data.account_collected_id:
111+ tax_account_id = tax_discount_data.account_collected_id.id
112+ else:
113+ tax_account_id = tax_discount_data.base_code_id.id
114+
115+ if line.debit>0.0:
116+ tax_discount_amt = 0.0
117+ tax_discount_amt = line.debit * tax_discount_data.amount
118+
119+ discount_lines.append(
120+ (0, 0, {
121+ 'name':line.name,
122+ 'debit':-(tax_discount_amt),
123+ 'credit':0.0,
124+ 'account_id':cash_discount_id,
125+ 'date':date,
126+ 'partner_id':line.partner_id.id,
127+ })),
128+
129+ discount_lines.append(
130+ (0, 0, {
131+ 'name':line.name,
132+ 'debit':0.0,
133+ 'credit':-(tax_discount_amt),
134+ 'account_id':tax_account_id,
135+ 'date':date,
136+ 'partner_id':line.partner_id.id,
137+ }))
138+
139+ elif line.credit>0.0:
140+ tax_discount_amt = 0.0
141+ tax_discount_amt = line.credit * tax_discount_data.amount
142+
143+ discount_lines.append(
144+ (0, 0, {
145+ 'name':line.name,
146+ 'debit':-(tax_discount_amt),
147+ 'credit':0.0,
148+ 'account_id':tax_account_id,
149+ 'date':date,
150+ 'partner_id':line.partner_id.id,
151+ }))
152+
153+ discount_lines.append(
154+ (0, 0, {
155+ 'name':line.name,
156+ 'debit':0.0,
157+ 'credit':-(tax_discount_amt),
158+ 'account_id':cash_discount_id,
159+ 'date':date,
160+ 'partner_id':line.partner_id.id,
161+ })),
162+
163+ account_move_obj.create(cr, uid,
164+ {
165+ 'period_id': period_id,
166+ 'journal_id': journal_id,
167+ 'date':date,
168+ 'state': 'draft',
169+ 'line_id': discount_lines
170+ })
171+
172+ return {}
173+
174+class wiz_period_writeoff_calculation(wizard.interface):
175+ states = {
176+ 'init': {
177+ 'actions': [],
178+ 'result': {'type': 'form', 'arch':_writeoff_entry_calculation_form, 'fields':_writeoff_entry_calculation_fields, 'state':[('calculate','Compute'),('end','Cancel')]}
179+ },
180+ 'calculate': {
181+ 'actions': [],
182+ 'result': {'type': 'action', 'action': _compute, 'state':'end'}
183+ }
184+ }
185+wiz_period_writeoff_calculation('account_period_write_calculation')
186+
187+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
188
189=== modified file 'account_payment_discount_extension/account_payment_discount.py'
190--- account_payment_discount_extension/account_payment_discount.py 2010-09-16 09:39:50 +0000
191+++ account_payment_discount_extension/account_payment_discount.py 2010-09-16 10:06:47 +0000
192@@ -102,7 +102,6 @@
193 string="Customer Cash Discount Account",
194 method=True,
195 view_load=True,
196- domain="[('type', '=', 'receivable')]",
197 required=True),
198 'property_supplier_cash_discount_account': fields.property(
199 'account.account',
200@@ -111,7 +110,6 @@
201 string="Supplier Cash Discount Account",
202 method=True,
203 view_load=True,
204- domain="[('type', '=', 'payable')]",
205 required=True),
206 }
207 res_partner()

Subscribers

People subscribed via source and target branches