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
=== modified file 'account_invoice_cash_discount/account_invoice_cash_discount_wizard.xml'
--- account_invoice_cash_discount/account_invoice_cash_discount_wizard.xml 2010-09-13 09:11:53 +0000
+++ account_invoice_cash_discount/account_invoice_cash_discount_wizard.xml 2010-09-16 10:39:51 +0000
@@ -14,5 +14,18 @@
14 name="account.move.line.discount.reconcile"14 name="account.move.line.discount.reconcile"
15 menu="True" 15 menu="True"
16 id="account.wizard_reconcile"/>16 id="account.wizard_reconcile"/>
17 <wizard
18 string="Compute Period Wise Write-off Entry"
19 model="account.move.line"
20 name="account_period_write_calculation"
21 menu="True"
22 id="wizard_period_writeoff_calculation"/>
23
24 <menuitem
25 action="wizard_period_writeoff_calculation"
26 id="menu_period_writeoff_calculation"
27 parent="account.menu_finance"
28 type="wizard"/>
29
17 </data>30 </data>
18</openerp>31</openerp>
1932
=== modified file 'account_invoice_cash_discount/wizard/__init__.py'
--- account_invoice_cash_discount/wizard/__init__.py 2010-09-13 09:11:53 +0000
+++ account_invoice_cash_discount/wizard/__init__.py 2010-09-16 10:39:51 +0000
@@ -23,6 +23,7 @@
23import account_pay_invoice23import account_pay_invoice
24import invoice_statement_payment24import invoice_statement_payment
25import wizard_discount_reconcile25import wizard_discount_reconcile
26import wizard_write_period_entry_calculation
2627
27# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:28# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
2829
2930
=== added file 'account_invoice_cash_discount/wizard/wizard_write_period_entry_calculation.py'
--- account_invoice_cash_discount/wizard/wizard_write_period_entry_calculation.py 1970-01-01 00:00:00 +0000
+++ account_invoice_cash_discount/wizard/wizard_write_period_entry_calculation.py 2010-09-16 10:39:51 +0000
@@ -0,0 +1,160 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
6# $Id$
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22
23import wizard
24import pooler
25import time
26from datetime import datetime
27from dateutil.relativedelta import relativedelta
28from mx import DateTime
29from tools.translate import _
30
31_writeoff_entry_calculation_form = '''<?xml version="1.0"?>
32<form string="Calculation">
33 <separator string="Calculation of period wise Write off Amount" colspan="4"/>
34 <field name="cash_discount_id"/>
35 <field name="tax_id"/>
36 <field name="period_id"/>
37 <field name="journal_id"/>
38</form>'''
39
40_writeoff_entry_calculation_fields = {
41 'cash_discount_id': {'string':'Cash Discount Account', 'type':'many2one', 'relation':'account.account', 'required':True},
42 'tax_id': {'string':'Taxes', 'type':'many2one', 'relation':'account.tax', 'required':True},
43 'period_id': {'string':'Period', 'type':'many2one', 'relation':'account.period', 'required':True},
44 'journal_id': {'string':'Journal', 'type':'many2one', 'relation':'account.journal', 'required':True},
45
46}
47
48def _compute(self, cr, uid, data, context):
49
50 pool = pooler.get_pool(cr.dbname)
51 payment_term_obj = pool.get('account.payment.term')
52 invoice_obj = pool.get('account.invoice')
53 account_move_line_obj = pool.get('account.move.line')
54 tax_obj = pool.get('account.tax')
55 account_move_obj= pool.get('account.move')
56
57 period_id = data['form']['period_id']
58 tax_id = data['form']['tax_id']
59 journal_id = data['form']['journal_id']
60 cash_discount_id = data['form']['cash_discount_id']
61
62 account_move_line_ids = account_move_line_obj.search(cr, uid, [('period_id','=',period_id),('account_id','=',cash_discount_id)])
63 date = time.strftime('%Y-%m-%d')
64
65 discount_lines = []
66
67 tax_account_id = False
68 dis_tax_code_id = False
69 discount_code_id = False
70
71 for line in account_move_line_obj.browse(cr, uid, account_move_line_ids, context=context):
72 tax_discount_amt = 0.0
73 tax_discount_data = tax_obj.browse(cr, uid, tax_id, context=context)
74 if tax_discount_data.account_collected_id:
75 tax_account_id = tax_discount_data.account_collected_id.id
76 else:
77 tax_account_id = tax_discount_data.tax_code_id.id
78
79 discount_code_id = tax_discount_data.base_code_id.id
80 dis_tax_code_id = tax_discount_data.tax_code_id.id
81
82 if line.debit>0.0:
83 tax_discount_amt = 0.0
84 tax_discount_amt = line.debit * tax_discount_data.amount
85
86 discount_lines.append(
87 (0, 0, {
88 'name':line.name,
89 'debit':tax_discount_amt,
90 'credit':0.0,
91 'account_id':cash_discount_id,
92 'date':date,
93 'partner_id':line.partner_id.id,
94 'tax_amount':-tax_discount_amt,
95 'tax_code_id':discount_code_id,
96 })),
97
98 discount_lines.append(
99 (0, 0, {
100 'name':line.name,
101 'debit':0.0,
102 'credit':tax_discount_amt,
103 'account_id':tax_account_id,
104 'date':date,
105 'partner_id':line.partner_id.id,
106 'tax_amount':-tax_discount_amt,
107 'tax_code_id':dis_tax_code_id,
108 }))
109
110 elif line.credit>0.0:
111 tax_discount_amt = 0.0
112 tax_discount_amt = line.credit * tax_discount_data.amount
113
114 discount_lines.append(
115 (0, 0, {
116 'name':line.name,
117 'debit':tax_discount_amt,
118 'credit':0.0,
119 'account_id':tax_account_id,
120 'date':date,
121 'partner_id':line.partner_id.id,
122 'tax_amount':-tax_discount_amt,
123 'tax_code_id':dis_tax_code_id,
124 }))
125
126 discount_lines.append(
127 (0, 0, {
128 'name':line.name,
129 'debit':0.0,
130 'credit':tax_discount_amt,
131 'account_id':cash_discount_id,
132 'date':date,
133 'partner_id':line.partner_id.id,
134 'tax_amount':-tax_discount_amt,
135 'tax_code_id':discount_code_id,
136 })),
137
138 account_move_obj.create(cr, uid,
139 {
140 'period_id': period_id,
141 'journal_id': journal_id,
142 'date':date,
143 'line_id': discount_lines
144 })
145 return {}
146
147class wiz_period_writeoff_calculation(wizard.interface):
148 states = {
149 'init': {
150 'actions': [],
151 'result': {'type': 'form', 'arch':_writeoff_entry_calculation_form, 'fields':_writeoff_entry_calculation_fields, 'state':[('calculate','Compute'),('end','Cancel')]}
152 },
153 'calculate': {
154 'actions': [],
155 'result': {'type': 'action', 'action': _compute, 'state':'end'}
156 }
157 }
158wiz_period_writeoff_calculation('account_period_write_calculation')
159
160# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
0161
=== modified file 'account_payment_discount_extension/account_payment_discount.py'
--- account_payment_discount_extension/account_payment_discount.py 2010-09-16 09:39:50 +0000
+++ account_payment_discount_extension/account_payment_discount.py 2010-09-16 10:39:51 +0000
@@ -102,7 +102,6 @@
102 string="Customer Cash Discount Account",102 string="Customer Cash Discount Account",
103 method=True,103 method=True,
104 view_load=True,104 view_load=True,
105 domain="[('type', '=', 'receivable')]",
106 required=True),105 required=True),
107 'property_supplier_cash_discount_account': fields.property(106 'property_supplier_cash_discount_account': fields.property(
108 'account.account',107 'account.account',
@@ -111,7 +110,6 @@
111 string="Supplier Cash Discount Account",110 string="Supplier Cash Discount Account",
112 method=True,111 method=True,
113 view_load=True,112 view_load=True,
114 domain="[('type', '=', 'payable')]",
115 required=True),113 required=True),
116 }114 }
117res_partner()115res_partner()

Subscribers

People subscribed via source and target branches