Odoo Help


This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Automatically send email from webshop without having the payment step [Closed]

on 10/28/15, 9:23 AM 564 views

The Question has been closed for reason: not relevant or out dated

on 11/12/2015 10:42:10

Hi guys,

Since a while I've been customizing the webshop but I've ran in to a problem.
I've changed the routes of quite some pages and how things work, but what is important for this issue is that the whole behaviour for the payment method has been taken out (this screen: http://i.imgur.com/y2SX6rp.png). This means that all functions regarding validating the order, setting the progress, sending the e-mail, ... have been lost. I've got everything working except for one thing: the e-mail.
My controller that should automatically send out the e-mail:

 @http.route(['/shop/final'], type='http', auth="user", website=True) 
    def final(self, **post):
        """ Payment step. This page proposes several payment means based on available
        payment.acquirer. State at this point :
         - a draft sale order with lines; otherwise, clean context / session and
           back to the shop
         - no transaction in context / session, or only a draft one, if the customer
           did go to a payment.acquirer website but closed the tab without
           paying / canceling
        cr, uid, context = request.cr, request.uid, request.context
        payment_obj = request.registry.get('payment.acquirer')
        sale_order_obj = request.registry.get('sale.order')

order = request.website.sale_get_order(context=context)
redirection = self.checkout_redirection(order) if redirection: return redirection shipping_partner_id = False if order: if order.partner_shipping_id.id: shipping_partner_id = order.partner_shipping_id.id else: shipping_partner_id = order.partner_invoice_id.id
values = { 'order': request.registry['sale.order'].browse(cr, SUPERUSER_ID, order.id, context=context) } values['errors'] = sale_order_obj._get_errors(cr, uid, order, context=context) values.update(sale_order_obj._get_website_data(cr, uid, order, context))
# fetch all registered payment means # if tx: # acquirer_ids = [tx.acquirer_id.id] # else: if not values['errors']: acquirer_ids = payment_obj.search(cr, SUPERUSER_ID, [('website_published', '=', True), ('company_id', '=', order.company_id.id)], context=context) values['acquirers'] = list(payment_obj.browse(cr, uid, acquirer_ids, context=context)) render_ctx = dict(context, submit_class='btn btn-primary', submit_txt=_('Pay Now')) for acquirer in values['acquirers']: acquirer.button = payment_obj.render( cr, SUPERUSER_ID, acquirer.id, order.name, order.amount_total, order.pricelist_id.currency_id.id, partner_id=shipping_partner_id, tx_values={ 'return_url': '/shop/payment/validate', }, context=render_ctx)

When I add this on the last line:

return request.website.render("website_sale.payment", values)

it will follow the default behaviour through different controllers/functions etc which automatically send out the e-mail. But this means the payment page has to be opened and used, which shouldn't happen in my case. So I added this on the last line of the function:

return request.redirect("/shop/final")

This will open a new webpage which shows some details to the user that the order is succesfully received and made. But due to changing the default behaviour my e-mail functionality is gone. After some searching/debugging I found out that the sending of the e-mail is triggered in payment_transfer/controllers/main.py in the function transfer_form_feedback and the line that send out the e-mail is the following:

request.registry['payment.transaction'].form_feedback(cr, uid, post, 'transfer', context)

The problem is that due to taking all payment behaviour out of my web application this doesn't get triggered and neither do all the other functions around this. So I was wondering: how can I make this request.registry work from within my controller? Something like this:

 @http.route(['/shop/final'], type='http', auth="user", website=True) 
def final(self, **post):
    //Irrelevant code
    request.registry['payment.transaction'].form_feedback(cr, uid, post, 'transfer', context)
    return request.redirect("/shop/final")

The problem is that when I add this line Odoo can't find the order and the result returned is an empty dict. So there is no reference to an order and the function crashes.
Does anybody know how I can trigger the e-mail to be automatically send with the order attached etc, just like the default behaviour? And this without using all the payment screens?


About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)


Asked: 10/28/15, 9:23 AM
Seen: 564 times
Last updated: 11/12/15, 10:42 AM