[IMP] website_sale: confirm quotation only when the payment is done, not directly when hitting 'pay now'.
This commit is contained in:
parent
428cb3fb13
commit
dce983dea0
|
@ -646,7 +646,6 @@ class website_sale(http.Controller):
|
||||||
"""
|
"""
|
||||||
cr, uid, context = request.cr, request.uid, request.context
|
cr, uid, context = request.cr, request.uid, request.context
|
||||||
transaction_obj = request.registry.get('payment.transaction')
|
transaction_obj = request.registry.get('payment.transaction')
|
||||||
sale_order_obj = request.registry['sale.order']
|
|
||||||
order = request.website.sale_get_order(context=context)
|
order = request.website.sale_get_order(context=context)
|
||||||
|
|
||||||
if not order or not order.order_line or acquirer_id is None:
|
if not order or not order.order_line or acquirer_id is None:
|
||||||
|
@ -676,13 +675,11 @@ class website_sale(http.Controller):
|
||||||
request.session['sale_transaction_id'] = tx_id
|
request.session['sale_transaction_id'] = tx_id
|
||||||
|
|
||||||
# update quotation
|
# update quotation
|
||||||
sale_order_obj.write(
|
request.registry['sale.order'].write(
|
||||||
cr, SUPERUSER_ID, [order.id], {
|
cr, SUPERUSER_ID, [order.id], {
|
||||||
'payment_acquirer_id': acquirer_id,
|
'payment_acquirer_id': acquirer_id,
|
||||||
'payment_tx_id': request.session['sale_transaction_id']
|
'payment_tx_id': request.session['sale_transaction_id']
|
||||||
}, context=context)
|
}, context=context)
|
||||||
# confirm the quotation
|
|
||||||
sale_order_obj.action_button_confirm(cr, SUPERUSER_ID, [order.id], context=request.context)
|
|
||||||
|
|
||||||
return tx_id
|
return tx_id
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
import product
|
import product
|
||||||
import sale_order
|
import sale_order
|
||||||
|
import payment
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from openerp import SUPERUSER_ID
|
||||||
|
from openerp.osv import orm, fields
|
||||||
|
|
||||||
|
|
||||||
|
class PaymentTransaction(orm.Model):
|
||||||
|
_inherit = 'payment.transaction'
|
||||||
|
|
||||||
|
_columns = {
|
||||||
|
# link with the sale order
|
||||||
|
'sale_order_id': fields.many2one('sale.order', 'Sale Order'),
|
||||||
|
}
|
||||||
|
|
||||||
|
def form_feedback(self, cr, uid, data, acquirer_name, context=None):
|
||||||
|
""" Override to confirm the sale order, if defined, and if the transaction
|
||||||
|
is done. """
|
||||||
|
tx = None
|
||||||
|
res = super(PaymentTransaction, self).form_feedback(cr, uid, data, acquirer_name, context=context)
|
||||||
|
|
||||||
|
# fetch the tx, check its state, confirm the potential SO
|
||||||
|
tx_find_method_name = '_%s_form_get_tx_from_data' % acquirer_name
|
||||||
|
if hasattr(self, tx_find_method_name):
|
||||||
|
tx = getattr(self, tx_find_method_name)(cr, uid, data, context=context)
|
||||||
|
if tx and tx.state == 'done' and tx.sale_order_id and tx.sale_order_id.state in ['draft', 'sent']:
|
||||||
|
self.pool['sale.order'].action_button_confirm(cr, SUPERUSER_ID, [tx.sale_order_id.id], context=context)
|
||||||
|
|
||||||
|
return res
|
|
@ -6,14 +6,6 @@ from openerp.osv import osv, orm, fields
|
||||||
from openerp.addons.web.http import request
|
from openerp.addons.web.http import request
|
||||||
|
|
||||||
|
|
||||||
class payment_transaction(orm.Model):
|
|
||||||
_inherit = 'payment.transaction'
|
|
||||||
|
|
||||||
_columns = {
|
|
||||||
# link with the sale order
|
|
||||||
'sale_order_id': fields.many2one('sale.order', 'Sale Order'),
|
|
||||||
}
|
|
||||||
|
|
||||||
class sale_order(osv.Model):
|
class sale_order(osv.Model):
|
||||||
_inherit = "sale.order"
|
_inherit = "sale.order"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue