Odoo Help


How do I check when a user is login or not when he is clicked on "shop" for shopping cart eCommerce?

on 7/7/16, 1:47 AM 544 views

Can i able to check like this?

<record id="shop_click" inherit_id="website_sale.menu_shop" name="is_shop_clicked">

    <xpath expr="//field[@url='/shop']" position="replace">

        <template id="login" inherit_id="auth_signup.signup" name="Sign up login">

            <t t-esc="Shop_click()">

            <xpath expr="//input[@name='redirect']" position="replace">

                <input type="hidden" name="redirect" t-att-value="redirect + '&amp;redirect=/shop' "/>





Axel Mendoza
On 7/7/16, 2:29 AM

If what you wanna accomplish is to make sure that the user is logged in before use the shop checkout you could find this helpful


*** Update: how to be able to make a function call inside a template ***

To be able to call a function in a template you are saying that you need to enhance the template generated code by calling a function, for that you have basically 2 ways:

1- You need to put that function inside the context of the template to be rendered. For example(taken from the controller of the module website_sale):

def get_attribute_value_ids(self, product):


attribute_value_ids = []


return attribute_value_ids






], type='http', auth="public", website=True)

def shop(self, page=0, category=None, search='', **post):


compute_currency = lambda price: pool['res.currency']._compute(cr, uid, from_currency, to_currency, price, context=context)

values = {


'compute_currency': compute_currency,


'get_attribute_value_ids': self.get_attribute_value_ids


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

2- Put the function in a model that is available already as a record value in the context of the template to be rendered so you just need to do for example:

<t t-raw="product.function_name"/>

There are others scenarios when you wanna execute some code into js or make a call to the server to execute the code in a server side controller.

Heartily thank you for your replay, can you please tell me that how to call a function inside a template

on 7/7/16, 2:52 AM

see my answer update for more

Axel Mendoza
on 7/7/16, 3:18 AM

Hi Mendoza can you please tell me that what is product stands in "product.function_name"

on 7/7/16, 5:15 AM

something like this:


from openerp import models, fields

class solt_product_template(model.Model):

_inherit = 'product.template'


def get_function_name(self):

for el in self:

el.function_name = '<h1>Hello</h1>'

function_name = fields.Html('Description for the website footer', compute='get_function_name')


Axel Mendoza
on 7/7/16, 5:34 AM

I didnt mean that code me just want to know that if it is something like that a variable or module.

on 7/7/16, 5:45 AM

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 7/7/16, 1:47 AM
Seen: 544 times
Last updated: 7/7/16, 2:29 AM