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
=== modified file 'account_invoice_cash_discount/account_invoice_cash_discount_wizard.xml'
--- account_invoice_cash_discount/account_invoice_cash_discount_wizard.xml 2010-06-30 05:22:29 +0000
+++ account_invoice_cash_discount/account_invoice_cash_discount_wizard.xml 2010-09-13 09:17:59 +0000
@@ -7,5 +7,12 @@
7 name="populate_statement_from_inv1"7 name="populate_statement_from_inv1"
8 menu="False"8 menu="False"
9 id="wizard_populate_statement_from_inv1"/>9 id="wizard_populate_statement_from_inv1"/>
10
11 <wizard
12 string="Reconcile Entries"
13 model="account.move.line"
14 name="account.move.line.discount.reconcile"
15 menu="True"
16 id="account.wizard_reconcile"/>
10 </data>17 </data>
11</openerp>18</openerp>
1219
=== modified file 'account_invoice_cash_discount/wizard/__init__.py'
--- account_invoice_cash_discount/wizard/__init__.py 2010-06-29 13:22:59 +0000
+++ account_invoice_cash_discount/wizard/__init__.py 2010-09-13 09:17:59 +0000
@@ -22,6 +22,7 @@
2222
23import account_pay_invoice23import account_pay_invoice
24import invoice_statement_payment24import invoice_statement_payment
25import wizard_discount_reconcile
2526
26# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:27# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
2728
2829
=== added file 'account_invoice_cash_discount/wizard/wizard_discount_reconcile.py'
--- account_invoice_cash_discount/wizard/wizard_discount_reconcile.py 1970-01-01 00:00:00 +0000
+++ account_invoice_cash_discount/wizard/wizard_discount_reconcile.py 2010-09-13 09:17:59 +0000
@@ -0,0 +1,179 @@
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 netsvc
25import time
26import osv
27import pooler
28from mx import DateTime as datetime
29from tools.translate import _
30
31_transaction_form = '''<?xml version="1.0"?>
32<form string="Reconciliation">
33 <separator string="Reconciliation transactions" colspan="4"/>
34 <field name="trans_nbr"/>
35 <newline/>
36 <field name="credit"/>
37 <field name="debit"/>
38 <separator string="Write-Off" colspan="4"/>
39 <field name="writeoff"/>
40</form>'''
41
42_transaction_fields = {
43 'trans_nbr': {'string':'# of Transaction', 'type':'integer', 'readonly':True},
44 'credit': {'string':'Credit amount', 'type':'float', 'readonly':True},
45 'debit': {'string':'Debit amount', 'type':'float', 'readonly':True},
46 'writeoff': {'string':'Write-Off amount', 'type':'float', 'readonly':True},
47}
48
49def _trans_rec_get(self, cr, uid, data, context=None):
50 pool = pooler.get_pool(cr.dbname)
51 account_move_line_obj = pool.get('account.move.line')
52 credit = debit = 0
53 account_id = False
54 count = 0
55 for line in account_move_line_obj.browse(cr, uid, data['ids'], context=context):
56 if not line.reconcile_id and not line.reconcile_id.id:
57 count += 1
58 credit += line.credit
59 debit += line.debit
60 account_id = line.account_id.id
61 return {'trans_nbr': count, 'account_id': account_id, 'credit': credit, 'debit': debit, 'writeoff': debit - credit}
62
63def _trans_rec_reconcile_partial(self, cr, uid, data, context=None):
64 pool = pooler.get_pool(cr.dbname)
65 account_move_line_obj = pool.get('account.move.line')
66 account_move_line_obj.reconcile_partial(cr, uid, data['ids'], 'manual', context=context)
67 return {}
68
69def _trans_rec_reconcile(self, cr, uid, data, context=None):
70 pool = pooler.get_pool(cr.dbname)
71 account_move_line_obj = pool.get('account.move.line')
72
73 form = data['form']
74 account_id = form.get('writeoff_acc_id', False) or form.get('discount_acc_id', False)
75 context['date_p'] = form.get('date_p', False)
76 date = False
77 if context['date_p']:
78 date = datetime.strptime(context['date_p'], '%Y-%m-%d')
79 ids = pool.get('account.period').find(cr, uid, dt=date, context=context)
80 period_id = False
81 if len(ids):
82 period_id = ids[0]
83
84 journal_id = form.get('journal_id', False)
85 context['comment'] = form.get('comment', False)
86 context['analytic_id'] = form.get('analytic_id', False)
87 account_move_line_obj.reconcile(cr, uid, data['ids'], 'manual', account_id,
88 period_id, journal_id, context=context)
89 return {}
90
91def _partial_check(self, cr, uid, data, context):
92 if _trans_rec_get(self,cr,uid, data, context)['writeoff'] == 0:
93 return 'init_full'
94 return 'init_partial'
95
96_transaction_add_form = '''<?xml version="1.0"?>
97<form string="Information addendum">
98 <separator string="Write-Off Move" colspan="4"/>
99 <field name="journal_id"/>
100 <field name="writeoff_acc_id" domain="[('type', '&lt;&gt;', 'view')]"/>
101 <field name="date_p"/>
102 <field name="comment"/>
103 <separator string="Analytic" colspan="4"/>
104 <field name="analytic_id"/>
105</form>'''
106
107_transaction_add_fields = {
108 'journal_id': {'string': 'Write-Off Journal', 'type': 'many2one', 'relation':'account.journal', 'required':True},
109 'writeoff_acc_id': {'string':'Write-Off account', 'type':'many2one', 'relation':'account.account', 'required':True},
110 'date_p': {'string':'Date','type':'date'},
111 'comment': {'string':'Comment','type':'char', 'size': 64, 'required':True},
112 'analytic_id': {'string':'Analytic Account', 'type': 'many2one', 'relation':'account.analytic.account'},
113}
114
115def _trans_rec_addendum(self, cr, uid, data, context={}):
116 date_p = time.strftime('%Y-%m-%d')
117 return {'date_p':date_p, 'comment': _('Write-Off')}
118
119_transaction_discount_form = '''<?xml version="1.0"?>
120<form string="Information Cash Discount">
121 <separator string="Cash Discount Move" colspan="4"/>
122 <field name="journal_id"/>
123 <field name="discount_acc_id" domain="[('type', '&lt;&gt;', 'view')]"/>
124 <field name="date_p"/>
125 <field name="comment"/>
126 <separator string="Analytic" colspan="4"/>
127 <field name="analytic_id"/>
128</form>'''
129
130_transaction_discount_fields = {
131 'journal_id': {'string': 'Cash Discount Journal', 'type': 'many2one', 'relation':'account.journal', 'required':True},
132 'discount_acc_id': {'string':'Cash Discount account', 'type':'many2one', 'relation':'account.account', 'required':True},
133 'date_p': {'string':'Date','type':'date'},
134 'comment': {'string':'Comment','type':'char', 'size': 64, 'required':True},
135 'analytic_id': {'string':'Analytic Account', 'type': 'many2one', 'relation':'account.analytic.account'},
136}
137
138def _trans_rec_discount(self, cr, uid, data, context={}):
139 date_p = time.strftime('%Y-%m-%d')
140 return {'date_p':date_p, 'comment': _('Cash Discount')}
141
142class wiz_reconcile(wizard.interface):
143 states = {
144 'init': {
145 'actions': [],
146 'result': {'type': 'choice', 'next_state': _partial_check}
147 },
148 'init_full': {
149 'actions': [_trans_rec_get],
150 'result': {'type': 'form', 'arch':_transaction_form, 'fields':_transaction_fields, 'state':[('end','Cancel'),('reconcile','Reconcile')]}
151 },
152 'init_partial': {
153 'actions': [_trans_rec_get],
154 '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')]}
155 },
156
157 'addendum': {
158 'actions': [_trans_rec_addendum],
159 'result': {'type': 'form', 'arch':_transaction_add_form, 'fields':_transaction_add_fields, 'state':[('end','Cancel'),('reconcile','Reconcile')]}
160 },
161
162 'discount': {
163 'actions': [_trans_rec_discount],
164 'result': {'type': 'form', 'arch':_transaction_discount_form, 'fields':_transaction_discount_fields, 'state':[('end','Cancel'),('reconcile','Reconcile')]}
165 },
166 'reconcile': {
167 'actions': [_trans_rec_reconcile],
168 'result': {'type': 'state', 'state':'end'}
169 },
170 'partial': {
171 'actions': [_trans_rec_reconcile_partial],
172 'result': {'type': 'state', 'state':'end'}
173 }
174 }
175wiz_reconcile('account.move.line.discount.reconcile')
176
177
178# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
179
0180
=== modified file 'sales_shop_stock_availability/sales_shop_stock_availability.py'
--- sales_shop_stock_availability/sales_shop_stock_availability.py 2010-09-09 09:34:39 +0000
+++ sales_shop_stock_availability/sales_shop_stock_availability.py 2010-09-13 09:17:59 +0000
@@ -50,8 +50,8 @@
50 if common_id:50 if common_id:
51 stock_common = self._product_available(cr, uid, common_id ,fields_name, context=context)51 stock_common = self._product_available(cr, uid, common_id ,fields_name, context=context)
52 for key,value in stock_common.items():52 for key,value in stock_common.items():
53 real_res[key] = stock_common[key]['qty_available']53 real_res[key] = 0.0
54 virtual_res[key] = stock_common[key]['virtual_available']54 virtual_res[key] = 0.0
5555
56 stock2 = self._product_available(cr, uid, simple_id ,fields_name,context={})56 stock2 = self._product_available(cr, uid, simple_id ,fields_name,context={})
57 context.update({'shop':shop})57 context.update({'shop':shop})
5858
=== modified file 'stock_minimum_calculator/wizard/stock_order_point_calculator.py'
--- stock_minimum_calculator/wizard/stock_order_point_calculator.py 2010-09-07 13:16:30 +0000
+++ stock_minimum_calculator/wizard/stock_order_point_calculator.py 2010-09-13 09:17:59 +0000
@@ -77,7 +77,6 @@
77 'string':"Method Calculation",77 'string':"Method Calculation",
78 'type':'selection',78 'type':'selection',
79 'selection':[('his_cons_with_product', 'Calculate with planning values'),79 'selection':[('his_cons_with_product', 'Calculate with planning values'),
80 ('his_cons_without_product', 'Calculate with Out historical consumptions of product'),
81 ('hist_cons_and_open_sale', 'Calculate with historical values'),80 ('hist_cons_and_open_sale', 'Calculate with historical values'),
82 ],'required': True,81 ],'required': True,
83 'default': lambda *a:'his_cons_with_product'82 'default': lambda *a:'his_cons_with_product'
@@ -85,14 +84,11 @@
85}84}
8685
87_messages_form = '''<?xml version="1.0"?>86_messages_form = '''<?xml version="1.0"?>
88<form string="Warning">87<form string="Message">
89 <label string="Information Regarding Method of Calculation" colspan="4"/>88 <label string="Calculations successfully done !" colspan="4"/>
90 <field name="message" colspan="4" nolabel="1"/>
91</form>'''89</form>'''
9290
93_message_fields = {91_message_fields = {}
94 'message': {'string':'Message' ,'type':'text', 'readonly':True}
95}
9692
97def _get_default(obj, cr, uid, data, context=None):93def _get_default(obj, cr, uid, data, context=None):
98 pool = pooler.get_pool(cr.dbname)94 pool = pooler.get_pool(cr.dbname)
@@ -315,10 +311,6 @@
315 product_min_qty = int(math.ceil(average_daily_consumption * (supplier_lead_time + purchase_lead_time) * seasonal_factor))311 product_min_qty = int(math.ceil(average_daily_consumption * (supplier_lead_time + purchase_lead_time) * seasonal_factor))
316 product_max_qty = max_qty_factor * product_min_qty312 product_max_qty = max_qty_factor * product_min_qty
317 313
318 elif data['form']['method_qty_calculation'] == 'his_cons_without_product':
319 product_min_qty = int(math.ceil(plan_average_daily_consumption * (supplier_lead_time + purchase_lead_time) * seasonal_factor))
320 product_max_qty = max_qty_factor * product_min_qty
321
322 else:314 else:
323 try:315 try:
324 product_min_qty = int(math.ceil((consum_qty + open_sale_qty) / pur_diff_day * (supplier_lead_time + purchase_lead_time) * seasonal_factor))316 product_min_qty = int(math.ceil((consum_qty + open_sale_qty) / pur_diff_day * (supplier_lead_time + purchase_lead_time) * seasonal_factor))
@@ -354,18 +346,6 @@
354 346
355 return {}347 return {}
356348
357def _get_message(self, cr, uid, data, context):
358
359 if data['form']['method_qty_calculation'] == 'his_cons_with_product':
360 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")
361 elif data['form']['method_qty_calculation'] == 'his_cons_without_product':
362 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")
363 else:
364 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.")
365 return data['form']
366
367
368
369class orderpoint_calculator(wizard.interface):349class orderpoint_calculator(wizard.interface):
370 states = {350 states = {
371 'init' : {351 'init' : {
@@ -382,7 +362,7 @@
382 },362 },
383363
384 'end2': {364 'end2': {
385 'actions': [ _get_message ],365 'actions': [],
386 'result': {'type': 'form', 'arch': _messages_form,366 'result': {'type': 'form', 'arch': _messages_form,
387 'fields': _message_fields,367 'fields': _message_fields,
388 'state': (368 'state': (

Subscribers

People subscribed via source and target branches