This question has been flagged
2 Replies
2375 Views

Hello there,

We have an Odoo 8 running with the last nightly code ( 9 novembre 2016).

With this version, should the cart be persistent after a logout/login of a visitor?

If a customer put some items in his cart on the shop, and he logs out, After he log again, should the items be still in his cart?

For the moment here, the cart is lost after each logout...

We ask it because we have many custom modules installed. Before to search the problem, we want to know if it should work or not...

Thanks


Avatar
Discard
Author

I have tested with a new clean server. No custom module. Just installed ecommerce module. The cart doesn't seem to be persistent... How could I solve it?

Author Best Answer

It seems to work now.

We put this code in a custom module :


class website_pt(orm.Model):
    _inherit = 'website'  
    def sale_get_order(self, cr, uid, ids, force_create=False, code=None, update_pricelist=None, context=None):
        sale_order_obj = self.pool['sale.order']
        sale_order_id = request.session.get('sale_order_id')
        sale_order = None
        # Cette partie a ete ajoutee afin que le panier se conserve quand un utilisateur revient.
        # https://github.com/odoo/odoo/issues/3339
        if not sale_order_id:
            partner = self.pool['res.users'].browse(cr, SUPERUSER_ID, uid, context=context).partner_id
             if partner and partner.id != 4: #(4 est le id du public user partner)
                domain = [('partner_id','=',partner.id), ('state','=','draft')]
                sale_order_id = sale_order_obj.search(cr, SUPERUSER_ID, domain, limit=1, context=context)


To override this code of the file odoo-8.0-20161109/openerp/addons/website_sale/models/sale_order.py  :


class website(orm.Model):
    _inherit = 'website'
    def sale_get_order(self, cr, uid, ids, force_create=False, code=None, update_pricelist=None, context=None):
        sale_order_obj = self.pool['sale.order']
        sale_order_id = request.session.get('sale_order_id')
        sale_order = None

Source : https://github.com/odoo/odoo/issues/3339

Avatar
Discard