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

Proposed by gpa(OpenERP)
Status: Merged
Merged at revision: 88
Proposed branch: lp:~openbig/bigconsulting/cash_discount_with_reconcile
Merge into: lp:bigconsulting
Diff against target: 296 lines (+193/-26)
5 files modified
account_invoice_cash_discount/account_invoice_cash_discount_wizard.xml (+7/-0)
account_invoice_cash_discount/wizard/__init__.py (+1/-0)
account_invoice_cash_discount/wizard/wizard_discount_reconcile.py (+179/-0)
sales_shop_stock_availability/sales_shop_stock_availability.py (+2/-2)
stock_minimum_calculator/wizard/stock_order_point_calculator.py (+4/-24)
To merge this branch: bzr merge lp:~openbig/bigconsulting/cash_discount_with_reconcile
Reviewer Review Type Date Requested Status
openbig Pending
Review via email: mp+35261@code.launchpad.net

Description of the change

Solved the bug of the cash discount with reconcile bug/634726

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-06-30 05:22:29 +0000
3+++ account_invoice_cash_discount/account_invoice_cash_discount_wizard.xml 2010-09-13 09:17:59 +0000
4@@ -7,5 +7,12 @@
5 name="populate_statement_from_inv1"
6 menu="False"
7 id="wizard_populate_statement_from_inv1"/>
8+
9+ <wizard
10+ string="Reconcile Entries"
11+ model="account.move.line"
12+ name="account.move.line.discount.reconcile"
13+ menu="True"
14+ id="account.wizard_reconcile"/>
15 </data>
16 </openerp>
17
18=== modified file 'account_invoice_cash_discount/wizard/__init__.py'
19--- account_invoice_cash_discount/wizard/__init__.py 2010-06-29 13:22:59 +0000
20+++ account_invoice_cash_discount/wizard/__init__.py 2010-09-13 09:17:59 +0000
21@@ -22,6 +22,7 @@
22
23 import account_pay_invoice
24 import invoice_statement_payment
25+import wizard_discount_reconcile
26
27 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
28
29
30=== added file 'account_invoice_cash_discount/wizard/wizard_discount_reconcile.py'
31--- account_invoice_cash_discount/wizard/wizard_discount_reconcile.py 1970-01-01 00:00:00 +0000
32+++ account_invoice_cash_discount/wizard/wizard_discount_reconcile.py 2010-09-13 09:17:59 +0000
33@@ -0,0 +1,179 @@
34+# -*- encoding: utf-8 -*-
35+##############################################################################
36+#
37+# OpenERP, Open Source Management Solution
38+# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
39+# $Id$
40+#
41+# This program is free software: you can redistribute it and/or modify
42+# it under the terms of the GNU General Public License as published by
43+# the Free Software Foundation, either version 3 of the License, or
44+# (at your option) any later version.
45+#
46+# This program is distributed in the hope that it will be useful,
47+# but WITHOUT ANY WARRANTY; without even the implied warranty of
48+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
49+# GNU General Public License for more details.
50+#
51+# You should have received a copy of the GNU General Public License
52+# along with this program. If not, see <http://www.gnu.org/licenses/>.
53+#
54+##############################################################################
55+
56+import wizard
57+import netsvc
58+import time
59+import osv
60+import pooler
61+from mx import DateTime as datetime
62+from tools.translate import _
63+
64+_transaction_form = '''<?xml version="1.0"?>
65+<form string="Reconciliation">
66+ <separator string="Reconciliation transactions" colspan="4"/>
67+ <field name="trans_nbr"/>
68+ <newline/>
69+ <field name="credit"/>
70+ <field name="debit"/>
71+ <separator string="Write-Off" colspan="4"/>
72+ <field name="writeoff"/>
73+</form>'''
74+
75+_transaction_fields = {
76+ 'trans_nbr': {'string':'# of Transaction', 'type':'integer', 'readonly':True},
77+ 'credit': {'string':'Credit amount', 'type':'float', 'readonly':True},
78+ 'debit': {'string':'Debit amount', 'type':'float', 'readonly':True},
79+ 'writeoff': {'string':'Write-Off amount', 'type':'float', 'readonly':True},
80+}
81+
82+def _trans_rec_get(self, cr, uid, data, context=None):
83+ pool = pooler.get_pool(cr.dbname)
84+ account_move_line_obj = pool.get('account.move.line')
85+ credit = debit = 0
86+ account_id = False
87+ count = 0
88+ for line in account_move_line_obj.browse(cr, uid, data['ids'], context=context):
89+ if not line.reconcile_id and not line.reconcile_id.id:
90+ count += 1
91+ credit += line.credit
92+ debit += line.debit
93+ account_id = line.account_id.id
94+ return {'trans_nbr': count, 'account_id': account_id, 'credit': credit, 'debit': debit, 'writeoff': debit - credit}
95+
96+def _trans_rec_reconcile_partial(self, cr, uid, data, context=None):
97+ pool = pooler.get_pool(cr.dbname)
98+ account_move_line_obj = pool.get('account.move.line')
99+ account_move_line_obj.reconcile_partial(cr, uid, data['ids'], 'manual', context=context)
100+ return {}
101+
102+def _trans_rec_reconcile(self, cr, uid, data, context=None):
103+ pool = pooler.get_pool(cr.dbname)
104+ account_move_line_obj = pool.get('account.move.line')
105+
106+ form = data['form']
107+ account_id = form.get('writeoff_acc_id', False) or form.get('discount_acc_id', False)
108+ context['date_p'] = form.get('date_p', False)
109+ date = False
110+ if context['date_p']:
111+ date = datetime.strptime(context['date_p'], '%Y-%m-%d')
112+ ids = pool.get('account.period').find(cr, uid, dt=date, context=context)
113+ period_id = False
114+ if len(ids):
115+ period_id = ids[0]
116+
117+ journal_id = form.get('journal_id', False)
118+ context['comment'] = form.get('comment', False)
119+ context['analytic_id'] = form.get('analytic_id', False)
120+ account_move_line_obj.reconcile(cr, uid, data['ids'], 'manual', account_id,
121+ period_id, journal_id, context=context)
122+ return {}
123+
124+def _partial_check(self, cr, uid, data, context):
125+ if _trans_rec_get(self,cr,uid, data, context)['writeoff'] == 0:
126+ return 'init_full'
127+ return 'init_partial'
128+
129+_transaction_add_form = '''<?xml version="1.0"?>
130+<form string="Information addendum">
131+ <separator string="Write-Off Move" colspan="4"/>
132+ <field name="journal_id"/>
133+ <field name="writeoff_acc_id" domain="[('type', '&lt;&gt;', 'view')]"/>
134+ <field name="date_p"/>
135+ <field name="comment"/>
136+ <separator string="Analytic" colspan="4"/>
137+ <field name="analytic_id"/>
138+</form>'''
139+
140+_transaction_add_fields = {
141+ 'journal_id': {'string': 'Write-Off Journal', 'type': 'many2one', 'relation':'account.journal', 'required':True},
142+ 'writeoff_acc_id': {'string':'Write-Off account', 'type':'many2one', 'relation':'account.account', 'required':True},
143+ 'date_p': {'string':'Date','type':'date'},
144+ 'comment': {'string':'Comment','type':'char', 'size': 64, 'required':True},
145+ 'analytic_id': {'string':'Analytic Account', 'type': 'many2one', 'relation':'account.analytic.account'},
146+}
147+
148+def _trans_rec_addendum(self, cr, uid, data, context={}):
149+ date_p = time.strftime('%Y-%m-%d')
150+ return {'date_p':date_p, 'comment': _('Write-Off')}
151+
152+_transaction_discount_form = '''<?xml version="1.0"?>
153+<form string="Information Cash Discount">
154+ <separator string="Cash Discount Move" colspan="4"/>
155+ <field name="journal_id"/>
156+ <field name="discount_acc_id" domain="[('type', '&lt;&gt;', 'view')]"/>
157+ <field name="date_p"/>
158+ <field name="comment"/>
159+ <separator string="Analytic" colspan="4"/>
160+ <field name="analytic_id"/>
161+</form>'''
162+
163+_transaction_discount_fields = {
164+ 'journal_id': {'string': 'Cash Discount Journal', 'type': 'many2one', 'relation':'account.journal', 'required':True},
165+ 'discount_acc_id': {'string':'Cash Discount account', 'type':'many2one', 'relation':'account.account', 'required':True},
166+ 'date_p': {'string':'Date','type':'date'},
167+ 'comment': {'string':'Comment','type':'char', 'size': 64, 'required':True},
168+ 'analytic_id': {'string':'Analytic Account', 'type': 'many2one', 'relation':'account.analytic.account'},
169+}
170+
171+def _trans_rec_discount(self, cr, uid, data, context={}):
172+ date_p = time.strftime('%Y-%m-%d')
173+ return {'date_p':date_p, 'comment': _('Cash Discount')}
174+
175+class wiz_reconcile(wizard.interface):
176+ states = {
177+ 'init': {
178+ 'actions': [],
179+ 'result': {'type': 'choice', 'next_state': _partial_check}
180+ },
181+ 'init_full': {
182+ 'actions': [_trans_rec_get],
183+ 'result': {'type': 'form', 'arch':_transaction_form, 'fields':_transaction_fields, 'state':[('end','Cancel'),('reconcile','Reconcile')]}
184+ },
185+ 'init_partial': {
186+ 'actions': [_trans_rec_get],
187+ 'result': {'type': 'form', 'arch':_transaction_form, 'fields':_transaction_fields, 'state':[('end','Cancel'),('addendum','Reconcile With Write-Off'),('discount','Reconcile With Cash Discount'), ('partial','Partial Reconcile')]}
188+ },
189+
190+ 'addendum': {
191+ 'actions': [_trans_rec_addendum],
192+ 'result': {'type': 'form', 'arch':_transaction_add_form, 'fields':_transaction_add_fields, 'state':[('end','Cancel'),('reconcile','Reconcile')]}
193+ },
194+
195+ 'discount': {
196+ 'actions': [_trans_rec_discount],
197+ 'result': {'type': 'form', 'arch':_transaction_discount_form, 'fields':_transaction_discount_fields, 'state':[('end','Cancel'),('reconcile','Reconcile')]}
198+ },
199+ 'reconcile': {
200+ 'actions': [_trans_rec_reconcile],
201+ 'result': {'type': 'state', 'state':'end'}
202+ },
203+ 'partial': {
204+ 'actions': [_trans_rec_reconcile_partial],
205+ 'result': {'type': 'state', 'state':'end'}
206+ }
207+ }
208+wiz_reconcile('account.move.line.discount.reconcile')
209+
210+
211+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
212+
213
214=== modified file 'sales_shop_stock_availability/sales_shop_stock_availability.py'
215--- sales_shop_stock_availability/sales_shop_stock_availability.py 2010-09-09 09:34:39 +0000
216+++ sales_shop_stock_availability/sales_shop_stock_availability.py 2010-09-13 09:17:59 +0000
217@@ -50,8 +50,8 @@
218 if common_id:
219 stock_common = self._product_available(cr, uid, common_id ,fields_name, context=context)
220 for key,value in stock_common.items():
221- real_res[key] = stock_common[key]['qty_available']
222- virtual_res[key] = stock_common[key]['virtual_available']
223+ real_res[key] = 0.0
224+ virtual_res[key] = 0.0
225
226 stock2 = self._product_available(cr, uid, simple_id ,fields_name,context={})
227 context.update({'shop':shop})
228
229=== modified file 'stock_minimum_calculator/wizard/stock_order_point_calculator.py'
230--- stock_minimum_calculator/wizard/stock_order_point_calculator.py 2010-09-07 13:16:30 +0000
231+++ stock_minimum_calculator/wizard/stock_order_point_calculator.py 2010-09-13 09:17:59 +0000
232@@ -77,7 +77,6 @@
233 'string':"Method Calculation",
234 'type':'selection',
235 'selection':[('his_cons_with_product', 'Calculate with planning values'),
236- ('his_cons_without_product', 'Calculate with Out historical consumptions of product'),
237 ('hist_cons_and_open_sale', 'Calculate with historical values'),
238 ],'required': True,
239 'default': lambda *a:'his_cons_with_product'
240@@ -85,14 +84,11 @@
241 }
242
243 _messages_form = '''<?xml version="1.0"?>
244-<form string="Warning">
245- <label string="Information Regarding Method of Calculation" colspan="4"/>
246- <field name="message" colspan="4" nolabel="1"/>
247+<form string="Message">
248+ <label string="Calculations successfully done !" colspan="4"/>
249 </form>'''
250
251-_message_fields = {
252- 'message': {'string':'Message' ,'type':'text', 'readonly':True}
253-}
254+_message_fields = {}
255
256 def _get_default(obj, cr, uid, data, context=None):
257 pool = pooler.get_pool(cr.dbname)
258@@ -315,10 +311,6 @@
259 product_min_qty = int(math.ceil(average_daily_consumption * (supplier_lead_time + purchase_lead_time) * seasonal_factor))
260 product_max_qty = max_qty_factor * product_min_qty
261
262- elif data['form']['method_qty_calculation'] == 'his_cons_without_product':
263- product_min_qty = int(math.ceil(plan_average_daily_consumption * (supplier_lead_time + purchase_lead_time) * seasonal_factor))
264- product_max_qty = max_qty_factor * product_min_qty
265-
266 else:
267 try:
268 product_min_qty = int(math.ceil((consum_qty + open_sale_qty) / pur_diff_day * (supplier_lead_time + purchase_lead_time) * seasonal_factor))
269@@ -354,18 +346,6 @@
270
271 return {}
272
273-def _get_message(self, cr, uid, data, context):
274-
275- if data['form']['method_qty_calculation'] == 'his_cons_with_product':
276- data['form']['message'] = _("Are your sure that you have enough historical data to calculate stock orderpoint rules with this methodology, Otherwise you should try the other options, \n Calculate without historical consumption of products or ,Calculate with historical consumption of products and sales orders")
277- elif data['form']['method_qty_calculation'] == 'his_cons_without_product':
278- data['form']['message'] = _("Your calculation is based on the field plan average daily consumption.\n Are your sure not to calculate with the method , Calculate with historical consumption of products")
279- else:
280- data['form']['message'] = _("Are your sure that you have really not enough historical data to calculate stock orderpoint rules? \n Otherwise you should prefer the options , Calculate with historical consumption of products. This results may calculate better results than calculation with this methodology.")
281- return data['form']
282-
283-
284-
285 class orderpoint_calculator(wizard.interface):
286 states = {
287 'init' : {
288@@ -382,7 +362,7 @@
289 },
290
291 'end2': {
292- 'actions': [ _get_message ],
293+ 'actions': [],
294 'result': {'type': 'form', 'arch': _messages_form,
295 'fields': _message_fields,
296 'state': (

Subscribers

People subscribed via source and target branches