In this article I am going to resolve web.login_layout QWebException (res_company.name) in Odoo, when I am using or add web.login_layout <t t-call="web.login_layout"> template in my custom template I am getting this error: QWeb Exception: "'NoneType' object has no attribute 'name'" while evaluating 'res_company.name'.
Web.login_layout QWebException | <t t-call="web.login_layout">
When I am calling below tempaltes in my custom module I am getting this error.
- <t t-call="web.login_layout">
- <t t-call="website.layout">
Error:- QWebException: "'NoneType' object has no attribute 'name'" while evaluating
'res_company.name'
To resolve above issue follow below code.
This is my custom template code that uses <t t-call="web.login_layout"> template.
Web.login_layout QWebException.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<openerp> | |
<data> | |
<template id="my_custom_form"> | |
<t t-call="web.login_layout"> | |
<form class="oe_signup_form" role="form" t-attf-action="/test/" method="post" onsubmit="this.action = this.action + location.hash"> | |
<div class="form-group field-login"> | |
<label for="name" class="control-label">Enter Name</label> | |
<input type="text" name="name" t-att-value="name" id="name" class="form-control" required="required" autofocus="autofocus"/> | |
</div> | |
<p class="alert alert-danger" t-if="error"> | |
<t t-esc="error"/> | |
</p> | |
<p class="alert alert-success" t-if="message"> | |
<t t-esc="message"/> | |
</p> | |
<div class="clearfix oe_login_buttons"> | |
<button type="submit" class="btn btn-primary">Submit</button> | |
<a href="/web/login" class="btn btn-link pull-right">Back to Login</a> | |
</div> | |
</form> | |
</t> | |
</template> | |
</data> | |
</openerp> |
Web.login_layout QWebException.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TestClass(http.Controller): | |
@http.route('/test/', type='http', auth='public') | |
def test_function(self, redirect=None, **kw): | |
if request.httprequest.method == 'POST': | |
return request.render('module_name.my_custom_form', { | |
'error': 'error message goes here', | |
'data': data, | |
}) | |
# To resolve this issue modify above controller with below one | |
class TestClass(http.Controller): | |
@http.route('/test/', type='http', auth='public', website=True) | |
def test_function(self, redirect=None, **kw): | |
if request.httprequest.method == 'POST': | |
return request.render('module_name.my_custom_form', { | |
'error': 'error message goes here', | |
'data': data, | |
}) |
Add website=True
@http.route('/test/', type='http', auth='public', website=True)
0 Comments