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
https://www.odoo.com/es_ES/forum/ayuda-1/question/login-feature-in-odoo-104396#answer-104427
*** 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
@http.route([
'/shop',
'/shop/page/<int:page>',
'/shop/category/<model("product.public.category"):category>',
'/shop/category/<model("product.public.category"):category>/page/<int:page>'
], 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.