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

Proposed by Serpent Consulting Services
Status: Merged
Merged at revision: 76
Proposed branch: lp:~serpent-consulting-services/openerp-usa/fix-shipping_api_ups_cc
Merge into: lp:openerp-usa/6.1.x
Diff against target: 40 lines (+29/-1)
1 file modified
account_payment_creditcard/stock_picking.py (+29/-1)
To merge this branch: bzr merge lp:~serpent-consulting-services/openerp-usa/fix-shipping_api_ups_cc
Reviewer Review Type Date Requested Status
npg Pending
Review via email: mp+120346@code.launchpad.net
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_payment_creditcard/stock_picking.py'
2--- account_payment_creditcard/stock_picking.py 2012-08-07 11:49:32 +0000
3+++ account_payment_creditcard/stock_picking.py 2012-08-20 08:38:21 +0000
4@@ -50,8 +50,36 @@
5 ("none", "Not Applicable"),
6 ("credit_card", "Credit Card"),
7 ("cc_refund", "Credit Card Refund")
8- ], "Invoice Control", select=True, required=True, readonly=True, states={'draft': [('readonly', False)]}),
9+ ], "Invoice Control", select=True, required=True, readonly=True, states={'draft': [('readonly', False)]}),
10+ 'ship_state': fields.selection([
11+ ('draft', 'Draft'),
12+ ('in_process', 'In Process'),
13+ ('ready_pick', 'Ready for Pickup'),
14+ ('shipped', 'Shipped'),
15+ ('delivered', 'Delivered'),
16+ ('void', 'Void'),
17+ ('hold', 'Hold'),
18+ ('cancelled', 'Cancelled')
19+ ], 'Shipping Status', readonly=True, help='The current status of the shipment'),
20+ 'ship_message': fields.text('Message'),
21 }
22+
23+ def action_process(self, cr, uid, ids, context=None):
24+ voucher_obj = self.pool.get('account.voucher')
25+ for deliv_order in self.browse(cr, uid, ids, context=context):
26+ do_transaction = True
27+ sale = deliv_order.sale_id or False
28+ if sale and sale.payment_method == 'cc_pre_auth' and not sale.invoiced:
29+ rel_voucher = sale.rel_account_voucher_id or False
30+ if rel_voucher and rel_voucher.state != 'posted' and rel_voucher.cc_auth_code:
31+ do_transaction = False
32+ voucher_obj.write(cr, uid, [rel_voucher_id], {'cc_p_authorize': False, 'cc_charge': True})
33+ do_transaction = voucher_obj.authorize(cr, uid, [rel_voucher.id], context=context)
34+ if not do_transaction:
35+ self.write(cr, uid, ids, {'ship_state': 'hold', 'ship_message': 'Unable to process creditcard payment.'})
36+ cr.commit()
37+ raise osv.except_osv(_('Final credit card charge cannot be completed!'), _("Please hold shipment and contact customer service."))
38+ return super(stock_picking, self).action_process(cr, uid, ids, context=context)
39
40 stock_picking()
41