Merge lp:~serpent-consulting-services/openerp-usa/openerp-usa-6.1-SerpentCS into lp:openerp-usa/6.1.x

Proposed by Serpent Consulting Services
Status: Merged
Merged at revision: 75
Proposed branch: lp:~serpent-consulting-services/openerp-usa/openerp-usa-6.1-SerpentCS
Merge into: lp:openerp-usa/6.1.x
Diff against target: 1215 lines (+211/-297)
14 files modified
account_payment_ccapi_authdotnet/__init__.py (+2/-0)
account_payment_ccapi_authdotnet/account_voucher.py (+1/-1)
account_payment_ccapi_authdotnet/account_voucher.xml (+0/-12)
account_payment_ccapi_authdotnet/cc_auth_api.py (+67/-62)
account_payment_ccapi_authdotnet/stock_return_picking.py (+34/-131)
account_payment_ccapi_authdotnet/stock_view.xml (+2/-2)
account_payment_creditcard/account_voucher.py (+4/-5)
account_payment_creditcard/account_voucher_view.xml (+0/-7)
account_payment_creditcard/sale.py (+4/-1)
account_payment_creditcard/stock_picking.py (+8/-1)
account_voucher_credits_us/__openerp__.py (+1/-1)
account_voucher_credits_us/voucher.py (+85/-43)
account_voucher_credits_us/voucher_payment_receipt_view.xml (+0/-25)
account_voucher_credits_us/wizard/account_post_voucher.py (+3/-6)
To merge this branch: bzr merge lp:~serpent-consulting-services/openerp-usa/openerp-usa-6.1-SerpentCS
Reviewer Review Type Date Requested Status
npg Pending
Review via email: mp+119535@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Serpent Consulting Services (serpent-consulting-services) wrote :

Thanks for the merge.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account_payment_ccapi_authdotnet/__init__.py'
2--- account_payment_ccapi_authdotnet/__init__.py 2012-08-06 11:40:00 +0000
3+++ account_payment_ccapi_authdotnet/__init__.py 2012-08-14 13:27:53 +0000
4@@ -19,7 +19,9 @@
5 # along with this program. If not, see <http://www.gnu.org/licenses/>
6 #
7 ##############################################################################
8+
9 import account_voucher
10 import cc_auth_api
11 import stock_return_picking
12+
13 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
14
15=== modified file 'account_payment_ccapi_authdotnet/account_voucher.py'
16--- account_payment_ccapi_authdotnet/account_voucher.py 2012-08-06 12:57:20 +0000
17+++ account_payment_ccapi_authdotnet/account_voucher.py 2012-08-14 13:27:53 +0000
18@@ -27,7 +27,7 @@
19 _inherit = 'account.voucher'
20
21 _columns = {
22- 'origin':fields.char('Origin', size=16, readonly=True)
23+ 'origin':fields.char('Origin', size=16, readonly=True),
24 }
25
26 account_voucher()
27
28=== modified file 'account_payment_ccapi_authdotnet/account_voucher.xml'
29--- account_payment_ccapi_authdotnet/account_voucher.xml 2012-08-06 11:40:00 +0000
30+++ account_payment_ccapi_authdotnet/account_voucher.xml 2012-08-14 13:27:53 +0000
31@@ -1,18 +1,6 @@
32 <?xml version="1.0" encoding="UTF-8"?>
33 <openerp>
34 <data>
35- <record id="account_voucher_changes_for_credit_card_02_inherit" model="ir.ui.view">
36- <field name="name">account_voucher_changes_for_credit_card_02.inherit</field>
37- <field name="model">account.voucher</field>
38- <field name="type">form</field>
39- <field name="inherit_id" ref="account_payment_creditcard.account_voucher_changes_for_credit_card_02"/>
40- <field name="arch" type="xml">
41- <xpath expr="//button[@name='authorize']" position="after">
42- <!-- button name="authorize" string="Authorize" type="object" colspan="2" attrs="{'readonly': [('state','!=','draft') ] }"/ -->
43- </xpath>
44- </field>
45- </record>
46-
47 <record id="view_sale_receipt_form_inherit_id" model="ir.ui.view">
48 <field name="name">account.voucher.sale.form.inherit</field>
49 <field name="model">account.voucher</field>
50
51=== modified file 'account_payment_ccapi_authdotnet/cc_auth_api.py'
52--- account_payment_ccapi_authdotnet/cc_auth_api.py 2012-08-06 13:01:00 +0000
53+++ account_payment_ccapi_authdotnet/cc_auth_api.py 2012-08-14 13:27:53 +0000
54@@ -22,7 +22,6 @@
55
56
57 from osv import osv, fields
58-import pooler
59 import socket
60 import sys
61 import urllib
62@@ -66,19 +65,20 @@
63 return False
64
65 def validate_sales_reciept(self, cr, uid, ids, context={}):
66+ voucher_obj = self.pool.get('account.voucher')
67 if type(ids) == type([]):
68- voucher_objs = self.pool.get('account.voucher').browse(cr, uid, ids, context=context)
69+ voucher_objs = voucher_obj.browse(cr, uid, ids, context=context)
70 else:
71- voucher_objs = self.pool.get('account.voucher').browse(cr, uid, [ids], context=context)
72+ voucher_objs = voucher_obj.browse(cr, uid, [ids], context=context)
73 for voucher_obj in voucher_objs:
74 rel_sale_order_id = voucher_obj.rel_sale_order_id.id
75- sale_reciepts_ids = self.pool.get('account.voucher').search(cr, uid, [('type', '=', 'sale'), ('rel_sale_order_id', '=', rel_sale_order_id), ('state', 'in', ['draft'])])
76+ sale_reciepts_ids = voucher_obj.search(cr, uid, [('type', '=', 'sale'), ('rel_sale_order_id', '=', rel_sale_order_id), ('state', 'in', ['draft'])])
77
78 if sale_reciepts_ids:
79- self.pool.get('account.voucher').action_move_line_create(cr, uid, sale_reciepts_ids, context=context)
80+ voucher_obj.action_move_line_create(cr, uid, sale_reciepts_ids, context=context)
81 else:
82 sale_reciepts_id = self.pool.get('sale.order').create_sales_reciept(cr, uid, [rel_sale_order_id], context=context)
83- self.pool.get('account.voucher').action_move_line_create(cr, uid, [sale_reciepts_id], context=context)
84+ voucher_obj.action_move_line_create(cr, uid, [sale_reciepts_id], context=context)
85 return True
86
87 def _get_prod_deb_acc(self, product_id, journal_obj, context=False):
88@@ -90,6 +90,7 @@
89 if journal_obj.default_debit_account_id:
90 return journal_obj.default_debit_account_id.id
91 return False
92+
93 def cancel_sales_reciept(self, cr, uid, ids, context={}):
94 voucher_obj = self.pool.get('account.voucher')
95 sale_obj = self.browse(cr, uid, ids, context=context)
96@@ -144,12 +145,15 @@
97 '''
98
99 ret = False
100+ voucher_obj = self.pool.get('account.voucher')
101+ partner_bank_obj = self.pool.get('res.partner.bank')
102+
103 wf_service = netsvc.LocalService("workflow")
104 if type([]) == type(ids):
105- acc_voucher_obj = pooler.get_pool(cr.dbname).get('account.voucher').browse(cr, uid, ids[0], context={'cc_no':'no_mask'})
106+ acc_voucher_obj = voucher_obj.browse(cr, uid, ids[0], context={'cc_no':'no_mask'})
107 else:
108- acc_voucher_obj = pooler.get_pool(cr.dbname).get('account.voucher').browse(cr, uid, ids, context={'cc_no':'no_mask'})
109- user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid)
110+ acc_voucher_obj = voucher_obj.browse(cr, uid, ids, context={'cc_no':'no_mask'})
111+ user = self.pool.get('res.users').browse(cr, uid, uid)
112 creditcard = acc_voucher_obj.cc_number# CREDIT CARD NUMBER
113 expiration = acc_voucher_obj.cc_e_d_month + acc_voucher_obj.cc_e_d_year ################ EXPIRATION DATE MM + YY
114 total = acc_voucher_obj.cc_order_amt ############## ORDER AMOUNT
115@@ -158,8 +162,8 @@
116 if not acc_voucher_obj.cc_bank:
117 raise osv.except_osv(_('No Bank selected!'), _("Please select the bank to save credit card details on customer bank details."))
118 else:
119- if not pooler.get_pool(cr.dbname).get('res.partner.bank').search(cr, uid, [('cc_number', '=', creditcard), ('partner_id', '=', acc_voucher_obj.partner_id.id)]):
120- pooler.get_pool(cr.dbname).get('res.partner.bank').create(cr, uid, {'state':'bank',
121+ if not partner_bank_obj.search(cr, uid, [('cc_number', '=', creditcard), ('partner_id', '=', acc_voucher_obj.partner_id.id)]):
122+ partner_bank_obj.create(cr, uid, {'state':'bank',
123 'acc_number':'nil',
124 'cc_number':creditcard,
125 'cc_e_d_month':acc_voucher_obj.cc_e_d_month,
126@@ -174,18 +178,18 @@
127 raise osv.except_osv(_('No Transaction ID!'), _(" Unable to find transaction id for refund."))
128 if not acc_voucher_obj.journal_id.cc_allow_refunds:
129 raise osv.except_osv(_('Unable to do Refund!'), _("Please check \"Allow Credit Card Refunds\" on journal to do refund."))
130+
131 elif acc_voucher_obj.cc_p_authorize:
132- x_type = 'AUTH_ONLY'
133+ x_type = 'AUTH_ONLY'
134
135 elif acc_voucher_obj.cc_charge:
136 x_type = 'AUTH_CAPTURE'
137 else:
138 raise osv.except_osv(_('No "Type of transaction"!'), _("No Transaction type selected. Please select pre-authorize or charge from \"Type of transaction\" section."))
139
140+ cvv = None
141 if acc_voucher_obj.cc_v:
142 cvv = acc_voucher_obj.cc_v
143- else:
144- cvv = None
145
146 tax = '0.00'
147
148@@ -206,7 +210,7 @@
149 #raise AuthnetAIMError('Invalid value for testmode. Must be True or False. "{0}" given.'.format(testmode))
150
151 parameters = {}
152- proxy = None;
153+ proxy = None
154 delimiter = '|'
155 results = []
156 error = True
157@@ -215,16 +219,16 @@
158
159 ############ initialize
160 parameters = {}
161- parameters = pooler.get_pool(cr.dbname).get('account.voucher').setParameter(parameters, 'x_delim_data', 'true')
162- parameters = pooler.get_pool(cr.dbname).get('account.voucher').setParameter(parameters, 'x_delim_data', 'true')
163- parameters = pooler.get_pool(cr.dbname).get('account.voucher').setParameter(parameters, 'x_delim_char', delimiter)
164- parameters = pooler.get_pool(cr.dbname).get('account.voucher').setParameter(parameters, 'x_relay_response', 'FALSE')
165- parameters = pooler.get_pool(cr.dbname).get('account.voucher').setParameter(parameters, 'x_url', 'FALSE')
166- parameters = pooler.get_pool(cr.dbname).get('account.voucher').setParameter(parameters, 'x_version', '3.1')
167- parameters = pooler.get_pool(cr.dbname).get('account.voucher').setParameter(parameters, 'x_method', 'CC')
168- parameters = pooler.get_pool(cr.dbname).get('account.voucher').setParameter(parameters, 'x_type', x_type)
169- parameters = pooler.get_pool(cr.dbname).get('account.voucher').setParameter(parameters, 'x_login', login)
170- parameters = pooler.get_pool(cr.dbname).get('account.voucher').setParameter(parameters, 'x_tran_key', transkey)
171+ parameters = voucher_obj.setParameter(parameters, 'x_delim_data', 'true')
172+ parameters = voucher_obj.setParameter(parameters, 'x_delim_data', 'true')
173+ parameters = voucher_obj.setParameter(parameters, 'x_delim_char', delimiter)
174+ parameters = voucher_obj.setParameter(parameters, 'x_relay_response', 'FALSE')
175+ parameters = voucher_obj.setParameter(parameters, 'x_url', 'FALSE')
176+ parameters = voucher_obj.setParameter(parameters, 'x_version', '3.1')
177+ parameters = voucher_obj.setParameter(parameters, 'x_method', 'CC')
178+ parameters = voucher_obj.setParameter(parameters, 'x_type', x_type)
179+ parameters = voucher_obj.setParameter(parameters, 'x_login', login)
180+ parameters = voucher_obj.setParameter(parameters, 'x_tran_key', transkey)
181
182 ########## setTransaction
183 if str(creditcard).strip() == '' or creditcard == None:
184@@ -238,25 +242,25 @@
185
186 #raise AuthnetAIMError('No total amount passed to setTransaction(): {0}').format(total)
187
188- parameters = pooler.get_pool(cr.dbname).get('account.voucher').setParameter(parameters, 'x_card_num', creditcard)
189- parameters = pooler.get_pool(cr.dbname).get('account.voucher').setParameter(parameters, 'x_exp_date', expiration)
190- parameters = pooler.get_pool(cr.dbname).get('account.voucher').setParameter(parameters, 'x_amount', total)
191+ parameters = voucher_obj.setParameter(parameters, 'x_card_num', creditcard)
192+ parameters = voucher_obj.setParameter(parameters, 'x_exp_date', expiration)
193+ parameters = voucher_obj.setParameter(parameters, 'x_amount', total)
194 if cvv != None:
195- parameters = pooler.get_pool(cr.dbname).get('account.voucher').setParameter(parameters, 'x_card_code', cvv)
196+ parameters = voucher_obj.setParameter(parameters, 'x_card_code', cvv)
197 if tax != None:
198- parameters = pooler.get_pool(cr.dbname).get('account.voucher').setParameter(parameters, 'x_tax', tax)
199+ parameters = voucher_obj.setParameter(parameters, 'x_tax', tax)
200 if invoice != None:
201- parameters = pooler.get_pool(cr.dbname).get('account.voucher').setParameter(parameters, 'x_invoice_num', invoice)
202+ parameters = voucher_obj.setParameter(parameters, 'x_invoice_num', invoice)
203
204 ##################initialize
205- parameters = pooler.get_pool(cr.dbname).get('account.voucher').setParameter(parameters, 'x_duplicate_window', 180)
206- parameters = acc_voucher_obj.cc_name and pooler.get_pool(cr.dbname).get('account.voucher').setParameter(parameters, 'x_first_name', acc_voucher_obj.cc_name or None) or parameters
207- parameters = acc_voucher_obj.cc_b_addr_1 and pooler.get_pool(cr.dbname).get('account.voucher').setParameter(parameters, 'x_address', acc_voucher_obj.cc_b_addr_1 or None) or parameters
208- parameters = acc_voucher_obj.cc_city and pooler.get_pool(cr.dbname).get('account.voucher').setParameter(parameters, 'x_city', acc_voucher_obj.cc_city or None) or parameters
209- parameters = acc_voucher_obj.cc_state and pooler.get_pool(cr.dbname).get('account.voucher').setParameter(parameters, 'x_state', acc_voucher_obj.cc_state or None) or parameters
210- parameters = acc_voucher_obj.cc_zip and pooler.get_pool(cr.dbname).get('account.voucher').setParameter(parameters, 'x_zip', acc_voucher_obj.cc_zip or None) or parameters
211- parameters = acc_voucher_obj.cc_country and pooler.get_pool(cr.dbname).get('account.voucher').setParameter(parameters, 'x_country', acc_voucher_obj.cc_country or None) or parameters
212- parameters = pooler.get_pool(cr.dbname).get('account.voucher').setParameter(parameters, 'x_customer_ip', socket.gethostbyname(socket.gethostname()))
213+ parameters = voucher_obj.setParameter(parameters, 'x_duplicate_window', 180)
214+ parameters = acc_voucher_obj.cc_name and voucher_obj.setParameter(parameters, 'x_first_name', acc_voucher_obj.cc_name or None) or parameters
215+ parameters = acc_voucher_obj.cc_b_addr_1 and voucher_obj.setParameter(parameters, 'x_address', acc_voucher_obj.cc_b_addr_1 or None) or parameters
216+ parameters = acc_voucher_obj.cc_city and voucher_obj.setParameter(parameters, 'x_city', acc_voucher_obj.cc_city or None) or parameters
217+ parameters = acc_voucher_obj.cc_state and voucher_obj.setParameter(parameters, 'x_state', acc_voucher_obj.cc_state or None) or parameters
218+ parameters = acc_voucher_obj.cc_zip and voucher_obj.setParameter(parameters, 'x_zip', acc_voucher_obj.cc_zip or None) or parameters
219+ parameters = acc_voucher_obj.cc_country and voucher_obj.setParameter(parameters, 'x_country', acc_voucher_obj.cc_country or None) or parameters
220+ parameters = voucher_obj.setParameter(parameters, 'x_customer_ip', socket.gethostbyname(socket.gethostname()))
221
222 # Actual Processing
223
224@@ -283,7 +287,7 @@
225 so_vals = {'cc_pre_auth':True, 'rel_account_voucher_id':acc_voucher_obj.id}
226 else:
227 so_vals = {'state':'cc_auth', 'cc_pre_auth':True, 'rel_account_voucher_id':acc_voucher_obj.id}
228- pooler.get_pool(cr.dbname).get('sale.order').write(cr, uid, [acc_voucher_obj.rel_sale_order_id.id], so_vals)
229+ self.pool.get('sale.order').write(cr, uid, [acc_voucher_obj.rel_sale_order_id.id], so_vals)
230
231 ret_dic = {'cc_auth_code':results[4],
232 'cc_trans_id':results[6]
233@@ -291,32 +295,32 @@
234 if x_type == 'AUTH_ONLY':
235 status = 'Authorization: ' + str(results[3])
236 ret_dic['cc_status'] = status
237- pooler.get_pool(cr.dbname).get('account.voucher').write(cr, uid, ids, ret_dic)
238+ voucher_obj.write(cr, uid, ids, ret_dic)
239+
240 elif x_type == 'AUTH_CAPTURE':
241 status = 'Prior Authorization and Capture: ' + str(results[3])
242 ret_dic['amount'] = acc_voucher_obj.cc_order_amt
243 ret_dic['cc_status'] = status
244 ret_dic['cc_transaction'] = True
245
246- pooler.get_pool(cr.dbname).get('account.voucher').write(cr, uid, ids, ret_dic)
247+ voucher_obj.write(cr, uid, ids, ret_dic)
248 cr.commit()
249 if results[0] == '1':
250 '''
251- Validating sales reciept
252+ Validating sales receipt
253 '''
254 #self.validate_sales_reciept(cr, uid, ids, context=context)
255
256 '''
257 Posting payment voucher
258 '''
259- pooler.get_pool(cr.dbname).get('account.voucher').action_move_line_create(cr, uid, ids, context)
260+ voucher_obj.action_move_line_create(cr, uid, ids, context)
261 ret = True
262+
263 elif x_type == 'CREDIT':
264- print "1" * 10, x_type
265 status = 'Refund: ' + str(results[3])
266 ret_dic['cc_status'] = status
267 if results[0] == '1':
268-
269 ret_dic['cc_transaction'] = False
270
271 #Domain : [('type','=','out_refund')]
272@@ -336,34 +340,34 @@
273 'type' : 'out_refund',
274 'journal_id': refund_journal_id,
275 'partner_id': acc_voucher_obj.partner_id.id,
276- 'shipcharge': context.get('cc_ship_refund'),
277- 'ship_method_id' : context.get('ship_method_id')
278+# 'shipcharge': context.get('cc_ship_refund'),
279+# 'ship_method_id' : context.get('ship_method_id')
280 }
281- if context.get('ship_method_id'):
282- ship_method = self.pool.get('shipping.rate.config').browse(cr, uid, context.get('ship_method_id'), context=context)
283- inv_vals['sale_account_id'] = ship_method.account_id and ship_method.account_id.id,
284+# if context.get('ship_method_id'):
285+# ship_method = self.pool.get('shipping.rate.config').browse(cr, uid, context.get('ship_method_id'), context=context)
286+# inv_vals['sale_account_id'] = ship_method.account_id and ship_method.account_id.id,
287
288 inv_vals.update(invoice_obj.onchange_partner_id(cr, uid, [], 'out_refund', acc_voucher_obj.partner_id.id, '', '', '', '')['value'])
289 inv_lines = []
290- for line in context['cc_refund']:
291+ refund_lines = context.get('cc_refund',[])
292+ for line in refund_lines:
293
294 inv_line_vals = {
295 'quantity' : line['qty'],
296 'product_id' : line['product_id'],
297- }
298+ }
299
300 onchage_vals = invoice_line_obj.product_id_change(cr, uid, [], line['product_id'], False, line['qty'], '', 'out_refund', inv_vals['partner_id'], False , inv_vals['address_invoice_id'] , False, False, {})['value']
301 onchage_vals['price_unit'] = line['price_unit']
302 inv_line_vals.update(onchage_vals)
303
304 inv_lines.append((0, 0, inv_line_vals))
305- inv_vals['abstract_line_ids'] = inv_lines
306-
307- print "Creating with val : ", inv_vals
308+
309+ inv_vals['invoice_line'] = inv_lines
310+
311 invoice_id = invoice_obj.create(cr, uid, inv_vals, context=context)
312 wf_service.trg_validate(uid, 'account.invoice', invoice_id, 'invoice_open', cr)
313
314- print "Created refund invoice and validated ", invoice_id
315 # ret = True
316 # voucher_obj = self.pool.get('account.voucher')
317 #
318@@ -458,12 +462,10 @@
319 # if not refund_voucher:
320 # wf_service = netsvc.LocalService('workflow')
321 # wf_service.trg_validate(uid, 'account.voucher', voucher_id, 'proforma_voucher', cr)
322-
323-
324
325 else:
326 ret_dic['cc_transaction'] = True
327- pooler.get_pool(cr.dbname).get('account.voucher').write(cr, uid, ids, ret_dic)
328+ voucher_obj.write(cr, uid, ids, ret_dic)
329 else:
330 status = ''
331
332@@ -480,7 +482,11 @@
333 '''
334
335 def authorize(self, cr, uid, ids, context=None):
336- return self.pool.get('auth.net.cc.api').do_this_transaction(cr, uid, ids, refund=False, context=context)
337+ res = self.pool.get('auth.net.cc.api').do_this_transaction(cr, uid, ids, refund=False, context=context)
338+ if res:
339+ wf_service = netsvc.LocalService("workflow")
340+ wf_service.trg_validate(uid, 'account.voucher', ids[0], 'proforma_voucher', cr)
341+ return True
342
343 def cc_refund(self, cr, uid, ids, context=None):
344 return self.pool.get('auth.net.cc.api').do_this_transaction(cr, uid, ids, refund=True, context=context)
345@@ -522,7 +528,6 @@
346 cr_ids['partner_id'] = sale_obj.partner_id.id
347 cr_ids['name'] = 'Shipping Charge for %s' % sale_line.name
348 cr_ids_list.append(cr_ids.copy())
349-
350
351 else:
352 vals['journal_id'] = False
353
354=== modified file 'account_payment_ccapi_authdotnet/stock_return_picking.py'
355--- account_payment_ccapi_authdotnet/stock_return_picking.py 2012-08-06 11:40:00 +0000
356+++ account_payment_ccapi_authdotnet/stock_return_picking.py 2012-08-14 13:27:53 +0000
357@@ -19,17 +19,18 @@
358 # along with this program. If not, see <http://www.gnu.org/licenses/>
359 #
360 ##############################################################################
361-import netsvc
362 import time
363
364-from osv import osv,fields
365+from osv import osv, fields
366 from tools.translate import _
367
368-
369 class stock_return_picking(osv.osv_memory):
370 _inherit = 'stock.return.picking'
371- _description = 'Return Picking'
372- _columns = { 'cc_ship_refund' : fields.boolean(string='Refund Shipcharge', required=True) }
373+ _columns = {
374+ 'cc_ship_refund' : fields.boolean(string='Refund Shipcharge', required=True),
375+ 'invoice_state': fields.selection([('2binvoiced', 'To be refunded/invoiced'), ('none', 'No invoicing'),('cc_refund','Credit Card Refund')], 'Invoicing',required=True),
376+ }
377+
378 def default_get(self, cr, uid, fields, context=None):
379 """
380 To get default values for the object.
381@@ -52,83 +53,6 @@
382 res['invoice_state'] = 'cc_refund'
383 return res
384
385- def view_init(self, cr, uid, fields_list, context=None):
386- """
387- Creates view dynamically and adding fields at runtime.
388- @param self: The object pointer.
389- @param cr: A database cursor
390- @param uid: ID of the user currently logged in
391- @param context: A standard dictionary
392- @return: New arch of view with new columns.
393- """
394-
395- if context is None:
396- context = {}
397- res = super(stock_return_picking, self).view_init(cr, uid, fields_list, context=context)
398- record_id = context and context.get('active_id', False)
399- if record_id:
400- pick_obj = self.pool.get('stock.picking')
401- pick = pick_obj.browse(cr, uid, record_id, context=context)
402- if 'invoice_state' in self._columns and pick.cc_pre_auth:
403- invoice_state_vals = [('2binvoiced', _('To be refunded/invoiced')), ('none', _('No invoicing')), ('cc_refund','Credit Card Refund')]
404- self._columns['invoice_state'] = fields.selection(invoice_state_vals, string='Invoicing', required=True)
405-
406- # if pick.sale_id and pick.sale_id.shipcharge and not pick.sale_id.cc_ship_refund :
407- # self._columns['cc_ship_refund'] = fields.boolean(string='Refund Shipcharge', required=True),
408-
409- return res
410-
411- def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
412- """
413- Changes the view dynamically
414- @param self: The object pointer.
415- @param cr: A database cursor
416- @param uid: ID of the user currently logged in
417- @param context: A standard dictionary
418- @return: New arch of view.
419- """
420- res = super(stock_return_picking, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar,submenu=False)
421- record_id = context and context.get('active_id', False)
422- active_model = context.get('active_model')
423- if active_model != 'stock.picking':
424- return res
425- if record_id:
426- pick_obj = self.pool.get('stock.picking')
427- pick = pick_obj.browse(cr, uid, record_id)
428- return_history = {}
429- res['fields'].clear()
430- arch_lst=['<?xml version="1.0"?>', '<form string="%s">' % _('Return lines'), '<label string="%s" colspan="4"/>' % _('Provide the quantities of the returned products.')]
431- for m in pick.move_lines:
432- return_history[m.id] = 0
433-
434- #print m.move_history_ids2
435-
436- for rec in m.move_history_ids2:
437- if m.id != rec.id:
438- return_history[m.id] += rec.product_qty
439- quantity = m.product_qty
440- if m.state=='done' and quantity > return_history[m.id]:
441- arch_lst.append('<field name="return%s"/>\n<newline/>' % (m.id,))
442- res['fields']['return%s' % m.id]={'string':m.name, 'type':'float', 'required':True}
443- res.setdefault('returns', []).append(m.id)
444- #print "1" * 10, res
445- arch_lst.append('<field name="invoice_state"/>\n<newline/>')
446- invoice_state_vals = [('2binvoiced', _('To be refunded/invoiced')), ('none', _('No invoicing'))]
447- if pick.cc_pre_auth:
448- invoice_state_vals.append(('cc_refund','Credit Card Refund'))
449- if pick.sale_id and pick.sale_id.shipcharge and not pick.sale_id.cc_ship_refund :
450- res['fields']['cc_ship_refund'] = {'string':'Refund Shipcharge','type':'boolean'}
451- arch_lst.append('<field name="cc_ship_refund"/>\n<newline/>')
452- res['fields']['invoice_state']={'string':_('Invoicing'), 'type':'selection','required':True, 'selection':invoice_state_vals}
453- arch_lst.append('<group col="2" colspan="4">')
454- arch_lst.append('<button icon="gtk-cancel" special="cancel" string="Cancel" />')
455- arch_lst.append('<button name="create_returns" string="Return" colspan="1" type="object" icon="gtk-apply" />')
456- arch_lst.append('</group>')
457- arch_lst.append('</form>')
458- res['arch'] = '\n'.join(arch_lst)
459- return res
460-
461-
462 def create_returns(self, cr, uid, ids, context=None):
463 """
464 Creates return picking.
465@@ -140,31 +64,31 @@
466 @return: A dictionary which of fields with values.
467 """
468 if context is None:
469- context = {}
470+ context = {}
471+
472+ res = super(stock_return_picking, self).create_returns(cr, uid, ids, context)
473+
474 record_id = context and context.get('active_id', False) or False
475 move_obj = self.pool.get('stock.move')
476 pick_obj = self.pool.get('stock.picking')
477- uom_obj = self.pool.get('product.uom')
478- seq_obj = self.pool.get('ir.sequence')
479- loc_obj = self.pool.get('stock.location')
480- warehouse_obj = self.pool.get('stock.warehouse')
481-
482- wf_service = netsvc.LocalService("workflow")
483-
484+ data_obj = self.pool.get('stock.return.picking.memory')
485+ voucher_obj = self.pool.get('account.voucher')
486 pick = pick_obj.browse(cr, uid, record_id, context=context)
487- data = self.read(cr, uid, ids[0])
488-
489- res = super(stock_return_picking, self).create_returns( cr, uid, ids, context)
490-
491- ctx=[]
492-
493+ data = self.read(cr, uid, ids[0], context=context)
494+ new_picking = None
495+
496+ vch_lines = []
497+ move_lines = data['product_return_moves']
498 #@ Moving the refund process to On Delivery process of related incoming shipment
499 if data['invoice_state'] == 'cc_refund':
500- amount=0.00
501- for move in pick.move_lines:
502- new_qty = data['return%s' % move.id]
503+ amount = 0.00
504+ for move in move_lines:
505+ return_line = data_obj.browse(cr, uid, move, context=context)
506+ mov_id = return_line.move_id.id
507+ new_qty = return_line.quantity
508+ move = move_obj.browse(cr, uid, mov_id, context=context)
509 amount = amount + new_qty * move.product_id.list_price
510- line ={}
511+ line = {}
512 line['product_id'] = move.product_id.id
513 line['qty'] = new_qty
514 line['price_unit'] = move.product_id.list_price
515@@ -173,60 +97,39 @@
516 if sale_line.product_id and sale_line.product_id.id == move.product_id.id:
517 line['price_unit'] = sale_line.price_unit
518 break
519+ vch_lines.append(line)
520
521- ctx.append(line)
522- if pick.sale_id and pick.sale_id.shipcharge and data.get('cc_ship_refund') and not pick.sale_id.cc_ship_refund :
523- amount=amount+pick.sale_id.shipcharge
524- context['cc_ship_refund'] = pick.sale_id.shipcharge
525- context['ship_method_id'] = pick.sale_id.ship_method_id and pick.sale_id.ship_method_id.id or False
526 if amount:
527- voucher_obj = self.pool.get('account.voucher')
528- voucher_ids = voucher_obj.search(cr,uid,[('rel_sale_order_id','=', pick.sale_id.id),('state','=','posted'),('type','=','receipt'),('cc_charge','=',True)], order="id desc",context=context)
529+ voucher_ids = voucher_obj.search(cr, uid, [('rel_sale_order_id', '=', pick.sale_id.id), ('state', '=', 'posted'), ('type', '=', 'receipt'), ('cc_charge', '=', True)], order="id desc", context=context)
530 if voucher_ids:
531- voucher_obj.write(cr, uid, [voucher_ids[0]], {'cc_order_amt':amount}, context )
532- context['cc_refund'] = ctx
533+ voucher_obj.write(cr, uid, [voucher_ids[0]], {'cc_order_amt':amount}, context=context)
534+ context['cc_refund'] = vch_lines
535
536- #self.pool.get('auth.net.cc.api').do_this_transaction(cr, uid, [voucher_ids[0]] , refund=True, context=context)
537+# self.pool.get('auth.net.cc.api').do_this_transaction(cr, uid, [voucher_ids[0]] , refund=True, context=context)
538 #voucher = voucher_obj.browse(cr, uid, voucher_ids[0] , context)
539
540 #@ Get picking id and write voucher_id
541 domain = res.get('domain') and eval(res['domain'])
542 new_pick_id = False
543- if domain and len(domain) and len(domain[0])==3:
544+ if domain and len(domain) and len(domain[0]) == 3:
545 new_pick_id = domain[0][2][0]
546 if new_pick_id:
547- self.pool.get('stock.picking').write(cr, uid, new_pick_id , {'voucher_id':voucher_ids[0]},context=context )
548-
549+ self.pool.get('stock.picking').write(cr, uid, new_pick_id, {'voucher_id':voucher_ids[0]}, context=context)
550 return res
551
552-
553 stock_return_picking()
554
555 class stock_picking(osv.osv):
556 _inherit = "stock.picking"
557 _columns = {
558-
559- 'invoice_state': fields.selection([
560- ("invoiced", "Invoiced"),
561- ("2binvoiced", "To Be Invoiced"),
562- ("none", "Not Applicable"),
563- ("credit_card", "Credit Card"),
564- ("cc_refund", "Credit Card Refund")
565- ], "Invoice Control", select=True, required=True, readonly=True, states={'draft': [('readonly', False)]}),
566- 'voucher_id' : fields.many2one('account.voucher','Refund Voucher', readonly=True)
567-
568- }
569+ 'voucher_id' : fields.many2one('account.voucher', 'Refund Voucher', readonly=True)
570+ }
571
572 def do_partial(self, cr, uid, ids, partial_datas, context=None):
573 res = super(stock_picking, self).do_partial(cr, uid, ids, partial_datas, context=context)
574 for pick in self.pool.get('stock.picking').browse(cr, uid, ids, context=context):
575- if pick.state =='done' and pick.invoice_state=='cc_refund' and pick.voucher_id:
576+ if pick.state == 'done' and pick.invoice_state == 'cc_refund' and pick.voucher_id:
577 self.pool.get('auth.net.cc.api').do_this_transaction(cr, uid, [pick.voucher_id.id] , refund=True, context=context)
578 return res
579-# def _get_invoice_type(self, pick):
580-#
581-# if pick.sale_id and pick.sale_id.order_policy=='credit_card':
582-# return 'credit_card'
583-# return super(stock_picking, self)._get_invoice_type(pick)
584 stock_picking()
585 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
586
587=== modified file 'account_payment_ccapi_authdotnet/stock_view.xml'
588--- account_payment_ccapi_authdotnet/stock_view.xml 2012-08-06 11:40:00 +0000
589+++ account_payment_ccapi_authdotnet/stock_view.xml 2012-08-14 13:27:53 +0000
590@@ -8,7 +8,7 @@
591 <field name="inherit_id" ref="stock.view_picking_form" />
592 <field name="arch" type="xml">
593 <xpath expr="//button[@name=%(stock.action_stock_invoice_onshipping)d]" position="replace">
594- <button name="%(stock.action_stock_invoice_onshipping)d" string="Create Invoice" attrs="{'invisible': ['|',('state','&lt;&gt;','done'),('invoice_state','=',[invoiced','none','cc_refund','credit_card']}" type="action" icon="terp-gtk-go-back-rtl" />
595+ <button name="%(stock.action_stock_invoice_onshipping)d" string="Create Invoice" attrs="{'invisible': ['|',('state','&lt;&gt;','done'),('invoice_state','=',['invoiced','none','cc_refund','credit_card'])]}" type="action" icon="terp-gtk-go-back-rtl" />
596 </xpath>
597 </field>
598 </record>
599@@ -20,7 +20,7 @@
600 <field name="inherit_id" ref="stock.view_picking_out_form" />
601 <field name="arch" type="xml">
602 <xpath expr="//button[@name=%(stock.action_stock_invoice_onshipping)d]" position="replace">
603- <button name="%(stock.action_stock_invoice_onshipping)d" string="Create Invoice" attrs="{'invisible': ['|',('state','&lt;&gt;','done'),('invoice_state','=',['invoiced','none','cc_refund','credit_card']}" type="action" icon="terp-gtk-go-back-rtl" />
604+ <button name="%(stock.action_stock_invoice_onshipping)d" string="Create Invoice" attrs="{'invisible': ['|',('state','&lt;&gt;','done'),('invoice_state','=',['invoiced','none','cc_refund','credit_card'])]}" type="action" icon="terp-gtk-go-back-rtl" />
605 </xpath>
606 </field>
607 </record>
608
609=== modified file 'account_payment_creditcard/account_voucher.py'
610--- account_payment_creditcard/account_voucher.py 2012-08-06 13:48:04 +0000
611+++ account_payment_creditcard/account_voucher.py 2012-08-14 13:27:53 +0000
612@@ -67,7 +67,7 @@
613 return False
614
615 def cc_refund(self, cr, uid, ids, context=None):
616- self.do_transaction(cr, uid, ids, refund=True,context=context)
617+# self.do_transaction(cr, uid, ids, refund=True,context=context)
618 return True
619
620 def _get_zip(self, cr, uid, ids, zip_id, context={}):
621@@ -222,8 +222,8 @@
622 'cc_auth_code':fields.char('Authorization Code', size=32),
623 'cc_save_card_details':fields.boolean('Save Credit Card details'),
624 'cc_ecommerce_sale':fields.boolean('Ecommerce sale'),
625- 'cc_p_authorize':fields.boolean('pre-authorize'),
626- 'cc_charge':fields.boolean('charge'),
627+ 'cc_p_authorize':fields.boolean('Pre-authorize'),
628+ 'cc_charge':fields.boolean('Charge'),
629 'cc_info_hide':fields.boolean('Credit Info Hide'),
630 'cc_status':fields.text('Status Message'),
631 'cc_details_autofill':fields.boolean('Credit Card Details Auto Fill'),
632@@ -240,7 +240,6 @@
633 'cc_p_authorize': lambda * a: True,
634 }
635
636-
637 def onchange_cc_details(self, cr, uid, ids, cc_details, context={}):
638 dic = {}
639 if cc_details:
640@@ -250,7 +249,7 @@
641 dic['cc_e_d_year'] = bank.cc_e_d_year
642 dic['cc_number'] = bank.cc_number
643 dic['cc_v'] = bank.cc_v
644- return{'value':dic}
645+ return {'value':dic}
646
647 def onchange_partner_id(self, cr, uid, ids, partner_id, journal_id, price, currency_id, ttype, date, context={}, sale_id=False):
648 res = super(account_voucher, self).onchange_partner_id(cr, uid, ids, partner_id, journal_id, price, currency_id, ttype, date, context=context)
649
650=== modified file 'account_payment_creditcard/account_voucher_view.xml'
651--- account_payment_creditcard/account_voucher_view.xml 2012-08-06 13:48:04 +0000
652+++ account_payment_creditcard/account_voucher_view.xml 2012-08-14 13:27:53 +0000
653@@ -7,13 +7,6 @@
654 <field name="type">form</field>
655 <field name="inherit_id" ref="account_voucher.view_vendor_receipt_form"/>
656 <field name="arch" type="xml">
657- <xpath expr="//field[@name='journal_id']" position="replace">
658- <field name="journal_id"
659- domain="[('type','in',['bank', 'cash'])]"
660- widget="selection" select="1"
661- on_change="onchange_partner_id(partner_id, journal_id, amount, currency_id, type, date, {}, rel_sale_order_id)"
662- string="Payment Method" />
663- </xpath>
664 <xpath expr="//field[@name='partner_id']" position='attributes'>
665 <attribute name='on_change'>onchange_partner_id(partner_id, journal_id, amount, currency_id, type, date, {}, rel_sale_order_id )</attribute>
666 </xpath>
667
668=== modified file 'account_payment_creditcard/sale.py'
669--- account_payment_creditcard/sale.py 2012-08-06 11:40:00 +0000
670+++ account_payment_creditcard/sale.py 2012-08-14 13:27:53 +0000
671@@ -84,6 +84,8 @@
672 'default_type':'receipt',
673 'default_journal_id':user.company_id.cc_journal_id and user.company_id.cc_journal_id.id or False,
674 'default_invoice_id':invoice_id,
675+ 'type': 'receipt',
676+ 'sale_id':ids[0]
677 }
678 }
679
680@@ -206,7 +208,8 @@
681 _defaults = {
682 'cc_ship_refund': lambda * a : False,
683 'payment_method': lambda * a: 'cc_pre_auth'
684- }
685+ }
686+
687 def action_ship_create(self, cr, uid, ids, *args):
688 ret = super(sale_order, self).action_ship_create(cr, uid, ids, args)
689 for sale_obj in self.browse(cr, uid, ids, context={}):
690
691=== modified file 'account_payment_creditcard/stock_picking.py'
692--- account_payment_creditcard/stock_picking.py 2012-08-06 11:40:00 +0000
693+++ account_payment_creditcard/stock_picking.py 2012-08-14 13:27:53 +0000
694@@ -27,7 +27,7 @@
695
696 _inherit = "stock.picking"
697 '''
698- Adding credit card preautohrised and payed check box on delivery order
699+ Adding credit card preauthorised and payed check box on delivery order
700 '''
701 def _get_sale_order(self, cr, uid, ids, context={}):
702 result = []
703@@ -44,6 +44,13 @@
704 _columns = {
705 'cc_pre_auth': fields.related('sale_id', 'cc_pre_auth', string='CC Pre-authorised', type='boolean'),
706 'invoiced': fields.related('sale_id', 'invoiced', string='Paid', type='boolean'),
707+ 'invoice_state': fields.selection([
708+ ("invoiced", "Invoiced"),
709+ ("2binvoiced", "To Be Invoiced"),
710+ ("none", "Not Applicable"),
711+ ("credit_card", "Credit Card"),
712+ ("cc_refund", "Credit Card Refund")
713+ ], "Invoice Control", select=True, required=True, readonly=True, states={'draft': [('readonly', False)]}),
714 }
715
716 stock_picking()
717
718=== modified file 'account_voucher_credits_us/__openerp__.py'
719--- account_voucher_credits_us/__openerp__.py 2012-08-06 13:01:00 +0000
720+++ account_voucher_credits_us/__openerp__.py 2012-08-14 13:27:53 +0000
721@@ -30,7 +30,7 @@
722 """,
723 "category": "US Localisation/Account",
724 "website": "http://www.novapointgroup.com/",
725- "depends": ["account_voucher", "account_payment_creditcard"],
726+ "depends": ["account_payment_creditcard"],
727 "init_xml": [],
728 "demo_xml": [],
729 "update_xml": [
730
731=== modified file 'account_voucher_credits_us/voucher.py'
732--- account_voucher_credits_us/voucher.py 2012-08-06 11:40:00 +0000
733+++ account_voucher_credits_us/voucher.py 2012-08-14 13:27:53 +0000
734@@ -45,8 +45,8 @@
735 else:
736 return
737 indices[i] += 1
738- for j in range(i+1, r):
739- indices[j] = indices[j-1] + 1
740+ for j in range(i + 1, r):
741+ indices[j] = indices[j - 1] + 1
742 yield tuple(pool[i] for i in indices)
743
744
745@@ -77,7 +77,7 @@
746
747 _columns = {
748 'amount_unreconciled': fields.function(_unreconciled, method=True, string='Unreconciled Amount'),
749- }
750+ }
751
752 account_move_line()
753
754@@ -130,7 +130,7 @@
755 else:
756 line.write({'amount': 0.0, 'pay': False}, context=context)
757 return True
758- if use_discount and total_amount > amount and (total_amount - amount ) <= total_discount_available: #It is possible to match using Discount
759+ if use_discount and total_amount > amount and (total_amount - amount) <= total_discount_available: #It is possible to match using Discount
760 # Unchecking all the lines other than matched line and uncheck all discount lines
761 line_ids = self.read(cr, uid, lines[0].voucher_id.id, ['line_ids'], context=context)['line_ids']
762 self.pool.get('account.voucher.line').write(cr, uid, line_ids, {'pay': False}, context=context)
763@@ -147,7 +147,7 @@
764 line.write({'amount': line.amount_unreconciled - line.credit_used - line.discount_used - line.writeoff_amount, 'pay': True }, context=context)
765 return True
766 if len(lines) > 1:
767- for combination in _combinations(lines, len(lines)-1):
768+ for combination in _combinations(lines, len(lines) - 1):
769 if self._find_exact_match(cr, uid, combination, amount, mark_pay=mark_pay, use_discount=use_discount, context=context):
770 return True
771 return False
772@@ -198,7 +198,7 @@
773 _columns = {
774 'number': fields.related('move_id', 'name', type="char", readonly=True, string='Number'),
775 'auto_match': fields.boolean('Use Automatic Matching')
776- }
777+ }
778
779 def onchange_partner_id(self, cr, uid, ids, partner_id, journal_id, price, currency_id, ttype, date, context={}, sale_id=False):
780 """price
781@@ -238,11 +238,9 @@
782 if date:
783 context_multi_currency.update({'date': date})
784
785-
786-
787 if not partner_id:
788 return default
789-
790+ line_ids = []
791 if not partner_id and ids:
792 line_ids = line_pool.search(cr, uid, [('voucher_id', '=', ids[0])], context=context)
793 if line_ids:
794@@ -281,12 +279,13 @@
795 partner_ids = partner_pool.search(cr, uid, [('parent_id', 'child_of', [partner_id])], context=context)
796 else:
797 partner_ids = [partner_id]
798- ids = move_line_pool.search(cr, uid, [('account_id.type', '=', account_type), ('reconcile_id', '=', False), ('partner_id', 'in', partner_ids)],
799+ ids = move_line_pool.search(cr, uid, [('account_id.type', '=', account_type), ('reconcile_id', '=', False), ('partner_id', 'in', partner_ids)],
800 context=context)
801 ids.reverse()
802 moves = move_line_pool.browse(cr, uid, ids, context=context)
803
804 company_currency = journal.company_id.currency_id.id
805+ company_id = journal.company_id.id
806 if company_currency != currency_id and ttype == 'payment':
807 total_debit = currency_pool.compute(cr, uid, currency_id, company_currency, total_debit, context=context_multi_currency)
808 elif company_currency != currency_id and ttype == 'receipt':
809@@ -301,7 +300,7 @@
810 total_debit += line.debit or 0.0
811
812 for line in moves:
813- if line.reconcile_partial_id and ttype=='receipt' and line.debit:
814+ if line.reconcile_partial_id and ttype == 'receipt' and line.debit:
815 continue
816 if line.credit and line.reconcile_partial_id and ttype == 'receipt':
817 continue
818@@ -354,7 +353,7 @@
819
820 total = reduce(lambda y, t: (t.debit or 0.0) - (t.credit or 0.0) + y, r.line_partial_ids, 0.0)
821
822- original_amount = line.credit
823+ original_amount = line.credit
824 amnt_org = currency_pool.compute(cr, uid, company_currency, currency_id, original_amount, context=context_multi_currency)
825 amnt_unr = currency_pool.compute(cr, uid, company_currency, currency_id, line.amount_unreconciled, context=context_multi_currency)
826 rs = {
827@@ -368,9 +367,11 @@
828 'amount_unreconciled': amnt_unr,
829 'amount': amnt_org - amnt_unr
830 }
831- vals = self.onchange_journal(cr, uid, ids, journal_id, line_ids, tax_id, partner_id, time.strftime('%Y-%m-%d'), price, ttype, company_id, context)
832- vals = vals.get('value')
833- currency_id = vals.get('currency_id', currency_id)
834+ if context.get('default_invoice_id'):
835+ rs['invoice_id'] = context.get('default_invoice_id',False)
836+# vals = self.onchange_journal(cr, uid, ids, journal_id, line_ids, False, partner_id, time.strftime('%Y-%m-%d'), price, ttype, company_id, context)
837+# vals = vals.get('value')
838+# currency_id = vals.get('currency_id', currency_id)
839
840 amount = currency_pool.compute(cr, uid, company_currency, currency_id, original_amount, context=context_multi_currency)
841 rs['amount'] = amount
842@@ -383,8 +384,6 @@
843 reconcile_ids.append(line.reconcile_partial_id.id)
844
845 default['value']['pre_line'] = 1
846-
847-
848
849 for credit_line in default['value']['line_dr_ids']:
850 credit_line['amount'] = credit_line['amount_original'] - credit_line['amount_unreconciled']
851@@ -392,6 +391,40 @@
852 invoice_line['amount'] = 0.0
853 invoice_line['amount_difference'] = invoice_line['amount_unreconciled']
854
855+ cardholder_details = self._get_cardholder_details(cr, uid, ids, partner_id, context=context)
856+ if journal_id and cardholder_details:
857+ jorurnal_cc_allow = self.pool.get('account.journal').read(cr, uid, journal_id, ['cc_allow_processing'])['cc_allow_processing']
858+ default['value']['cc_name'] = cardholder_details['name']
859+ default['value']['cc_b_addr_1'] = cardholder_details['street']
860+ default['value']['cc_b_addr_2'] = cardholder_details['street2']
861+ default['value']['cc_city'] = cardholder_details['city']
862+ default['value']['cc_country'] = cardholder_details['country']
863+ default['value']['cc_zip'] = cardholder_details['zip']
864+ default['value']['cc_state'] = cardholder_details['state']
865+ default['value']['cc_reseller'] = cardholder_details['title'] == 'Reseller' and True or False
866+ default['value']['cc_save_card_details'] = False
867+ if jorurnal_cc_allow:
868+ default['value']['cc_info_hide'] = False
869+ else:
870+ default['value']['cc_info_hide'] = True
871+
872+ if not sale_id:
873+ sale_id = context.get('sale_id')
874+
875+ if sale_id and default['value'].get('line_cr_ids') :
876+ sale = self.pool.get('sale.order').browse(cr, uid, sale_id, context=context)
877+ lines = []
878+ for line in default['value']['line_cr_ids']:
879+ for invoice in sale.invoice_ids:
880+ if not (line.get('invoice_id') and line.get('invoice_id') and line['invoice_id'] == invoice.id):
881+ line['pay'] = False
882+ else:
883+ line['pay'] = True
884+ line['amount'] = line['amount_original']
885+
886+ lines.append(line)
887+ default['value']['line_cr_ids'] = lines
888+
889 return default
890
891 def calc_cash_discount(self, vch, line, amount=0):
892@@ -470,7 +503,7 @@
893 'currency_id': vch.currency_id.id,
894 'amount_currency': vch.amount,
895 'date': vch.date,
896- 'date_maturity': vch.date_due
897+ 'date_maturity': vch.date_due,
898 }
899
900 if (debit == 0.0 or credit == 0.0 or debit + credit > 0) and (debit > 0.0 or credit > 0.0):
901@@ -513,7 +546,8 @@
902 'quantity': 1,
903 'credit': 0.0,
904 'debit': 0.0,
905- 'date': vch.date
906+ 'date': vch.date,
907+ 'invoice_id':line.invoice_id.id or False
908 }
909 if line.invoice_id:
910 move_line['partner_id'] = line.invoice_id.partner_id.id
911@@ -546,7 +580,7 @@
912
913 if line.invoice_id.id:
914 invoice = self.pool.get('account.invoice').browse(cr, uid, line.invoice_id.id, context=context)
915- types = {'out_invoice': -1, 'in_invoice': 1, 'out_refund': 1, 'in_refund': -1}
916+ types = {'out_invoice':-1, 'in_invoice': 1, 'out_refund': 1, 'in_refund':-1}
917 direction = types[invoice.type]
918
919 # Post Discount Lines for supplier
920@@ -561,7 +595,7 @@
921 'debit': direction * available_discounts.discount_amount > 0 and direction * available_discounts.discount_amount,
922 'credit': direction * available_discounts.discount_amount < 0 and - direction * available_discounts.discount_amount,
923 'account_id': line.account_id.id,
924- 'partner_id': line.move_line_id.partner_id.id,
925+ 'partner_id': line.move_line_id.partner_id.id,
926 'move_id': move_id,
927 'ref': 'Cash Discount',
928 'name': line.name or '/',
929@@ -569,6 +603,7 @@
930 'currency_id': vch.currency_id.id,
931 'amount_currency': available_discounts.discount_amount and - direction * available_discounts.discount_amount or 0.0,
932 'company_id': line.company_id.id,
933+ 'invoice_id':line.invoice_id.id or False
934 }
935 l2 = {
936 'journal_id': vch.journal_id.id,
937@@ -584,11 +619,12 @@
938 'currency_id': vch.currency_id.id,
939 'amount_currency': available_discounts.discount_amount and - direction * available_discounts.discount_amount or 0.0,
940 'company_id': line.company_id.id,
941+ 'invoice_id':line.invoice_id.id or False
942 }
943 name = invoice.number
944 l1['name'] = name
945 l2['name'] = name
946- move_lines = [l1,l2]
947+ move_lines = [l1, l2]
948 for move_line in move_lines:
949 master_line = move_line_pool.create(cr, uid, move_line, context=context)
950 if line.move_line_id.id and move_line['account_id'] == line.move_line_id.account_id.id:
951@@ -613,6 +649,7 @@
952 'currency_id': vch.currency_id.id,
953 'amount_currency': available_discounts.discount_amount and - direction * available_discounts.discount_amount or 0.0,
954 'company_id': line.company_id.id,
955+ 'invoice_id':line.invoice_id.id or False
956 }
957 l2 = {
958 'journal_id': vch.journal_id.id,
959@@ -628,6 +665,7 @@
960 'currency_id': vch.currency_id.id,
961 'amount_currency': available_discounts.discount_amount and - direction * available_discounts.discount_amount or 0.0,
962 'company_id': line.company_id.id,
963+ 'invoice_id':line.invoice_id.id or False
964 }
965 name = invoice.number
966 l1['name'] = name
967@@ -647,7 +685,7 @@
968 'debit': direction * writeoff.writeoff_amount > 0 and direction * writeoff.writeoff_amount,
969 'credit': direction * writeoff.writeoff_amount < 0 and - direction * writeoff.writeoff_amount,
970 'account_id': line.account_id.id,
971- 'partner_id': line.move_line_id.partner_id.id,
972+ 'partner_id': line.move_line_id.partner_id.id,
973 'move_id': move_id,
974 'ref': 'Writeoff',
975 'name': line.name or '/',
976@@ -655,6 +693,7 @@
977 'currency_id': vch.currency_id.id,
978 'amount_currency': writeoff.writeoff_amount and - direction * writeoff.writeoff_amount or 0.0,
979 'company_id': line.company_id.id,
980+ 'invoice_id':line.invoice_id.id or False
981 }
982 l2 = {
983 'journal_id': vch.journal_id.id,
984@@ -670,6 +709,7 @@
985 'currency_id': vch.currency_id.id,
986 'amount_currency': writeoff.writeoff_amount and - direction * writeoff.writeoff_amount or 0.0,
987 'company_id': line.company_id.id,
988+ 'invoice_id':line.invoice_id.id or False
989 }
990 name = invoice.number
991 l1['name'] = name
992@@ -695,6 +735,7 @@
993 'credit': 0.00,
994 'debit': total_discount,
995 'currency_id': vch.currency_id.id,
996+ 'invoice_id':line.invoice_id.id or False
997 }
998
999 move_line_credit_id = move_line_pool.create(cr, uid, move_line, context=contexts)
1000@@ -708,8 +749,9 @@
1001 'partner_id': vch.partner_id.id,
1002 'date': vch.date,
1003 'credit': diff > 0 and diff or 0.0,
1004- 'debit': diff < 0 and -diff or 0.0,
1005+ 'debit': diff < 0 and - diff or 0.0,
1006 'currency_id': vch.currency_id.id,
1007+ 'invoice_id':line.invoice_id.id or False
1008 }
1009 account_id = False
1010 if vch.type in ('sale', 'receipt'):
1011@@ -752,8 +794,8 @@
1012 if len(rec_ids) >= 2:
1013 move_line_pool.reconcile_partial(cr, uid, rec_ids)
1014
1015- move_line_ids = move_line_pool.search(cr, uid, [('account_id', '=', vch.partner_id.property_account_receivable.id ),
1016- ('partner_id', '=', vch.partner_id.id), ('reconcile_id', '=', False),
1017+ move_line_ids = move_line_pool.search(cr, uid, [('account_id', '=', vch.partner_id.property_account_receivable.id),
1018+ ('partner_id', '=', vch.partner_id.id), ('reconcile_id', '=', False),
1019 ('move_id', '=', move_id), ('debit', '>', 0.00)], context=context)
1020 move_lines2 = []
1021 for credit_line in vch.line_cr_ids:
1022@@ -762,7 +804,7 @@
1023 if available_credit.use_credit and available_credit.discount_amount and available_credit.inv_credit:
1024 move_lines2.append(available_credit.inv_credit.id)
1025 if vch.type == 'receipt':
1026- move_line_ids = list(set(move_line_ids + move_lines2))
1027+ move_line_ids = list(set(move_line_ids + move_lines2))
1028 if move_line_ids:
1029 debit = 0.00
1030 credit = 0.00
1031@@ -778,8 +820,8 @@
1032 except Exception:
1033 pass
1034 move_line_ids = move_line_pool.search(cr, uid, [
1035- ('account_id', '=', vch.partner_id.property_account_receivable.id ),
1036- ('partner_id', '=', vch.partner_id.id),
1037+ ('account_id', '=', vch.partner_id.property_account_receivable.id),
1038+ ('partner_id', '=', vch.partner_id.id),
1039 ('reconcile_id', '=', False)
1040 ], context=context)
1041 if move_line_ids:
1042@@ -822,10 +864,10 @@
1043 'gl_account': credit_line.account_id.id,
1044 }, context=context)
1045 else :
1046- to_update_credit_line_ids = credits_used_pool.search(cr,uid,[('voucher_line_id', '=', line.id),
1047+ to_update_credit_line_ids = credits_used_pool.search(cr, uid, [('voucher_line_id', '=', line.id),
1048 ('orginal_credit_line_id', '=', credit_line.id)], context=context)
1049 if to_update_credit_line_ids:
1050- credits_used_pool.write(cr, uid,to_update_credit_line_ids,
1051+ credits_used_pool.write(cr, uid, to_update_credit_line_ids,
1052 {'available_amount': credit_line.amount_unreconciled - credit_line.pending_credits}, context=context)
1053
1054 def write(self, cr, user, ids, vals, context=None):
1055@@ -882,7 +924,7 @@
1056 res[line.id] = 0.0
1057 for credit_line in line.available_credits:
1058 if credit_line.use_credit :
1059- res[line.id] += credit_line.discount_amount
1060+ res[line.id] += credit_line.discount_amount
1061 return res
1062
1063 def _compute_balance(self, cr, uid, ids, name, args, context=None):
1064@@ -947,15 +989,15 @@
1065 _columns = {
1066 'invoice_id': fields.many2one('account.invoice', 'Invoice'),
1067 'account_id': fields.many2one('account.account', 'G/L Account', required=True),
1068- 'amount': fields.float('Payment Amt', digits=(14,2), required=True),
1069- 'date_due': fields.related('move_line_id', 'date_maturity', type='date', relation='account.move.line', string='Due Date', readonly=True ,
1070+ 'amount': fields.float('Payment Amt', digits=(14, 2), required=True),
1071+ 'date_due': fields.related('move_line_id', 'date_maturity', type='date', relation='account.move.line', string='Due Date', readonly=True ,
1072 store={
1073 'account.voucher.line': (lambda self, cr, uid, ids, c={}: ids, ['move_line_id'], 20),
1074 'account.move.line': (_get_due_date, ['date_maturity'], 20),
1075 }),
1076 'amount_original': fields.function(_compute_balance, method=True, multi='dc', type='float', string='Original Amt', store=True, readonly=True),
1077 'amount_unreconciled': fields.function(_compute_balance, method=True, multi='dc', type='float', string='Amt Due', store=True, readonly=True),
1078- 'company_id': fields.related('voucher_id','company_id', type='many2one', relation='res.company', string='Company',
1079+ 'company_id': fields.related('voucher_id', 'company_id', type='many2one', relation='res.company', string='Company',
1080 store={
1081 'account.voucher': (_get_voucher_line_ids, ['company_id'], 20),
1082 }),
1083@@ -966,7 +1008,7 @@
1084 'writeoff': fields.boolean("Writeoff"),
1085 'pay': fields.boolean("Pay", required=True),
1086 'pending_credits': fields.function(_credits_calc, method=True, string='Pending Credits Used', type='float'),
1087- 'available_credits': fields.one2many('account.voucher.line.credits_to_use', 'voucher_line_id', 'Available credits' ),
1088+ 'available_credits': fields.one2many('account.voucher.line.credits_to_use', 'voucher_line_id', 'Available credits'),
1089 'discount_used': fields.function(_compute_discount_used, method=True, type='float', string='Discount Used', store=False, readonly=True),
1090 'writeoff_amount': fields.function(_calc_writeoff, method=True, string='Write-off Amt', type='float', store=False,),
1091 }
1092@@ -991,16 +1033,16 @@
1093 voucher_line_credits_to_use_obj = self.pool.get('account.voucher.line.credits_to_use')
1094 voucher_line_discount_to_use_obj = self.pool.get('account.voucher.line.discount_to_use')
1095 credit_val = {
1096- 'use_credit': False,
1097+ 'use_credit': False,
1098 'discount_amount': 0.0
1099 }
1100 discount_val = {
1101- 'use_discount': False,
1102+ 'use_discount': False,
1103 'discount_amount': 0.0
1104 }
1105 if hasattr(voucher_line, 'writeoff_ids'):
1106 if hasattr(voucher_line, 'available_discounts'):
1107- for lines in self.read(cr, uid, ids,['available_credits', 'writeoff_ids', 'available_discounts'], context=context):
1108+ for lines in self.read(cr, uid, ids, ['available_credits', 'writeoff_ids', 'available_discounts'], context=context):
1109 voucher_line_writeoff_obj.unlink(cr, uid, lines['writeoff_ids'], context=context)
1110 voucher_line_credits_to_use_obj.write(cr, uid, lines['available_credits'], credit_val, context=context)
1111 voucher_line_discount_to_use_obj.write(cr, uid, lines['available_discounts'], discount_val, context=context)
1112@@ -1009,15 +1051,15 @@
1113 voucher_line_writeoff_obj.unlink(cr, uid, lines['writeoff_ids'], context=context)
1114 voucher_line_credits_to_use_obj.write(cr, uid, lines['available_credits'], credit_val, context=context)
1115 elif hasattr(voucher_line, 'available_discounts'):
1116- for lines in self.read(cr, uid, ids,['available_credits', 'available_discounts'], context=context):
1117+ for lines in self.read(cr, uid, ids, ['available_credits', 'available_discounts'], context=context):
1118 voucher_line_credits_to_use_obj.write(cr, uid, lines['available_credits'], credit_val, context=context)
1119 voucher_line_discount_to_use_obj.write(cr, uid, lines['available_discounts'], discount_val, context=context)
1120 else:
1121- for lines in self.read(cr, uid, ids,['available_credits'], context=context):
1122+ for lines in self.read(cr, uid, ids, ['available_credits'], context=context):
1123 voucher_line_credits_to_use_obj.write(cr, uid, lines['available_credits'], credit_val, context=context)
1124 return True
1125
1126- def onchange_pay(self, cr, uid, ids, line_amount, pay, amount_unreconciled,par_cr_ids, par_amount, credit_used, discount_used=0,
1127+ def onchange_pay(self, cr, uid, ids, line_amount, pay, amount_unreconciled, par_cr_ids, par_amount, credit_used, discount_used=0,
1128 writeoff_amount=0, context=None):
1129 """
1130 Function to automatically fill the values when the pay checkbox is selected
1131@@ -1098,7 +1140,7 @@
1132 res['warning'] = {'title': _('Credit not in the limit'), 'message': _('Credit should not be a negative value.')}
1133 elif discount_amount > available_amount:
1134 res['value'] = {'discount_amount': available_amount, 'use_credit': True}
1135- res['warning'] = {'title': _('Credit not in the limit'),
1136+ res['warning'] = {'title': _('Credit not in the limit'),
1137 'message': _('Please adjust the Credit Amt value to be less than or equal the Credit Available.')}
1138 elif discount_amount == 0.0:
1139 res['value'] = {'use_credit': False}
1140
1141=== modified file 'account_voucher_credits_us/voucher_payment_receipt_view.xml'
1142--- account_voucher_credits_us/voucher_payment_receipt_view.xml 2012-08-06 11:40:00 +0000
1143+++ account_voucher_credits_us/voucher_payment_receipt_view.xml 2012-08-14 13:27:53 +0000
1144@@ -190,31 +190,6 @@
1145 </xpath>
1146 </field>
1147 </record>
1148- <!--
1149- Company
1150- -->
1151- <record id="view_company_form_jdc3" model="ir.ui.view">
1152- <field name="name">res.company.form.jdc3</field>
1153- <field name="model">res.company</field>
1154- <field name="type">form</field>
1155- <field name="inherit_id" ref="base.view_company_form"/>
1156- <field name="priority" eval="1"/>
1157- <field name="arch" type="xml">
1158- <xpath expr="/form/notebook/page[@string='Configuration']" position="inside">
1159- <group>
1160- <separator string="Supplier Payment" colspan="2"/><newline/>
1161- <field name="def_supp_journal" domain="[('type','in',['bank','cash'])]"/>
1162- </group>
1163- </xpath>
1164-
1165- <xpath expr="/form/notebook" position="inside">
1166- <page string="Accounting">
1167- <field name="writeoff_account" colspan="2"/>
1168- </page>
1169- </xpath>
1170- </field>
1171- </record>
1172-
1173
1174 </data>
1175 </openerp>
1176
1177=== modified file 'account_voucher_credits_us/wizard/account_post_voucher.py'
1178--- account_voucher_credits_us/wizard/account_post_voucher.py 2012-08-06 11:40:00 +0000
1179+++ account_voucher_credits_us/wizard/account_post_voucher.py 2012-08-14 13:27:53 +0000
1180@@ -30,7 +30,7 @@
1181 'total_paid': fields.float('Total Received'),
1182 'total_allocated': fields.float('Total Allocated'),
1183 'ok_to_go': fields.float('OK to Go'),
1184- }
1185+ }
1186
1187 def _get_total_paid(self, cr, uid, context=None):
1188 """
1189@@ -81,15 +81,13 @@
1190 return total_allocated
1191 for line in voucher.line_cr_ids:
1192 total_allocated += line.amount
1193-
1194-
1195 return total_allocated - voucher.amount
1196
1197 _defaults = {
1198 'total_paid': _get_total_paid,
1199 'total_allocated': _get_total_allocated,
1200 'ok_to_go': _get_ok_to_go,
1201- }
1202+ }
1203
1204 def onchange_ok_to_go(self, cr, uid, ids, ok_to_go, context=None):
1205 """
1206@@ -102,8 +100,7 @@
1207 """
1208 if ok_to_go > 0.0:
1209 return {'warning': {'title': _('Overallocated invoices'), 'message': _('Reduce allocations to match Total Receipt')}}
1210- else:
1211- return {'value': {}}
1212+ return {'value': {}}
1213
1214 def launch_wizard(self, cr, uid, ids, context=None):
1215 """