[FIX] website_quote: Do not generate invoices twice

- When paying with stripe an error occurs because of a callback generating the invoice for the SO which is called now automatically by the payment system
This commit is contained in:
tbe-odoo
2017-10-27 11:45:50 +02:00
committed by Nicolas Martinelli
parent 7c639be4aa
commit e51fa63bda
2 changed files with 2 additions and 21 deletions
+2 -10
View File
@@ -186,11 +186,7 @@ class sale_quote(http.Controller):
token = request.env['payment.token'].sudo() # currently no support of payment tokens
tx = request.env['payment.transaction'].sudo().search([('reference', '=', order.name)], limit=1)
tx_type = order._get_payment_type()
tx = tx._check_or_create_sale_tx(order, acquirer, payment_token=token, tx_type=tx_type, add_tx_values={
'callback_model_id': request.env['ir.model'].sudo().search([('model', '=', order._name)], limit=1).id,
'callback_res_id': order.id,
'callback_method': '_confirm_online_quote',
})
tx = tx._check_or_create_sale_tx(order, acquirer, payment_token=token, tx_type=tx_type)
request.session['quote_%s_transaction_id' % order.id] = tx.id
return tx.render_sale_button(order, '/quote/%s/%s' % (order_id, access_token) if access_token else '/quote/%s' % order_id,
@@ -222,11 +218,7 @@ class sale_quote(http.Controller):
# set the transaction type to server2server
tx_type = 'server2server'
# check if the transaction exists, if not then it create one
tx = tx._check_or_create_sale_tx(order, token.acquirer_id, payment_token=token, tx_type=tx_type, add_tx_values={
'callback_model_id': request.env['ir.model'].sudo().search([('model', '=', order._name)], limit=1).id,
'callback_res_id': order.id,
'callback_method': '_confirm_online_quote',
})
tx = tx._check_or_create_sale_tx(order, token.acquirer_id, payment_token=token, tx_type=tx_type)
# set the transaction id into the session
request.session['quote_%s_transaction_id' % order_id] = tx.id
# proceed to the payment
-11
View File
@@ -201,17 +201,6 @@ class SaleOrder(models.Model):
return 'sign' if self.require_payment == 1 else 'pay'
return super(SaleOrder, self).get_portal_confirmation_action()
@api.multi
def _confirm_online_quote(self, transaction):
""" Payment callback: validate the order and write transaction details in chatter """
# create draft invoice if transaction is ok
if transaction and transaction.state == 'done':
transaction._confirm_so()
message = _('Order paid by %s. Transaction: %s. Amount: %s.') % (transaction.partner_id.name, transaction.acquirer_reference, transaction.amount)
self.message_post(body=message)
return True
return False
@api.multi
def action_confirm(self):
res = super(SaleOrder, self).action_confirm()