我正在使用Odoo v9创建一个网站,当有人导航到我网站的某个页面(/订单/时间)时,他会得到下面详述的错误。
型号:
from openerp import models, fields, api
class odss_sale_order(models.Model):
_name = "_order"
order_date = fields.Text(required=True)
观点的重要部分:
<div class="row form-group">
<div class="input-group">
<div t-field="odss_order.order_date"/>
</div>
</div>
</div>
错误:
&#39; NoneType&#39;对象没有属性&#39; _fields&#39;
回溯:
Traceback(最近一次调用最后一次):文件 &#34; /opt/odoo/addons/website/models/ir_http.py" ;,第243行,在 _handle_exception response = super(ir_http,self)._ handle_exception(exception)File&#34; /opt/odoo/openerp/addons/base/ir/ir_http.py" ;,第157行,in _handle_exception 在_handle_exception中返回request._handle_exception(exception)File&#34; /opt/odoo/openerp/http.py" ;,第784行 return super(HttpRequest,self)._ handle_exception(exception)File&#34; /opt/odoo/openerp/addons/base/ir/ir_http.py" ;,第182行,in _调度 result = request.dispatch()File&#34; /opt/odoo/openerp/http.py" ;, line 843,in dispatch r = self._call_function(** self.params)文件&#34; /opt/odoo/openerp/http.py",第319行,_call_function return checked_call(self.db,* args,** kwargs)File&#34; /opt/odoo/openerp/service/model.py" ;,第118行,在包装器中 返回f(dbname,* args,** kwargs)文件&#34; /opt/odoo/openerp/http.py" ;,第315行,在checked_call中 result.flatten()File&#34; /opt/odoo/openerp/http.py" ;, line 1444,flatten self.response.append(self.render())File&#34; /opt/odoo/openerp/http.py" ;,第1437行,渲染 context = request.context)文件&#34; /opt/odoo/openerp/api.py" ;,第250行,在包装器中 返回old_api(self,* args,** kwargs)文件&#34; /opt/odoo/addons/website/models/ir_ui_view.py",第166行,在渲染中 return super(view,self).render(cr,uid,id_or_xml_id,values = values,engine = engine,context = context)File &#34; /opt/odoo/openerp/api.py" ;,第250行,在包装器中 返回old_api(self,* args,** kwargs)文件&#34; /opt/odoo/addons/web_editor/models/ir_ui_view.py",第29行,在渲染中 return super(view,self).render(cr,uid,id_or_xml_id,values = values,engine = engine,context = context)File &#34; /opt/odoo/openerp/api.py" ;,第250行,在包装器中 返回old_api(self,* args,** kwargs)文件&#34; /opt/odoo/openerp/addons/base/ir/ir_ui_view.py",第1074行,在渲染中 return self.pool [engine] .render(cr,uid,id_or_xml_id,qcontext,loader = loader,context = context)File&#34; /opt/odoo/openerp/api.py", 第250行,包装中 返回old_api(self,* args,** kwargs)文件&#34; /opt/odoo/openerp/addons/base/ir/ir_qweb.py" ;,第254行,在渲染中 return self.render_node(element,qwebcontext,generated_attributes = qwebcontext.pop(&#39; generated_attributes&#39;,&#39;&#39;))
文件&#34; /opt/odoo/openerp/addons/base/ir/ir_qweb.py",第297行, render_node result = self.render_element(element,template_attributes,generated_attributes,qwebcontext)文件 &#34; /opt/odoo/openerp/addons/base/ir/ir_qweb.py" ;,第320行,在 render_element generated_attributes = name ==&#34; t&#34;和generated_attributes或&#39;&#39;))文件&#34; /opt/odoo/openerp/addons/base/ir/ir_qweb.py",第295行, render_node result = self._render_tag [t_render](self,element,template_attributes,generated_attributes,qwebcontext)文件 &#34; /opt/odoo/openerp/addons/base/ir/ir_qweb.py" ;,第448行,在 render_tag_call d [0] = self.render_element(element,template_attributes,generated_attributes,d)文件 &#34; /opt/odoo/openerp/addons/base/ir/ir_qweb.py" ;,第320行,在 render_element generated_attributes = name ==&#34; t&#34;和generated_attributes或&#39;&#39;))文件&#34; /opt/odoo/openerp/addons/base/ir/ir_qweb.py",第297行, render_node result = self.render_element(element,template_attributes,generated_attributes,qwebcontext)文件 &#34; /opt/odoo/openerp/addons/base/ir/ir_qweb.py" ;,第320行,在 render_element generated_attributes = name ==&#34; t&#34;和generated_attributes或&#39;&#39;))文件&#34; /opt/odoo/openerp/addons/base/ir/ir_qweb.py",第297行, render_node result = self.render_element(element,template_attributes,generated_attributes,qwebcontext)文件 &#34; /opt/odoo/openerp/addons/base/ir/ir_qweb.py" ;,第320行,在 render_element generated_attributes = name ==&#34; t&#34;和generated_attributes或&#39;&#39;))文件&#34; /opt/odoo/openerp/addons/base/ir/ir_qweb.py",第297行, render_node result = self.render_element(element,template_attributes,generated_attributes,qwebcontext)文件 &#34; /opt/odoo/openerp/addons/base/ir/ir_qweb.py" ;,第320行,在 render_element generated_attributes = name ==&#34; t&#34;和generated_attributes或&#39;&#39;))文件&#34; /opt/odoo/openerp/addons/base/ir/ir_qweb.py",第297行, render_node result = self.render_element(element,template_attributes,generated_attributes,qwebcontext)文件 &#34; /opt/odoo/openerp/addons/base/ir/ir_qweb.py" ;,第320行,在 render_element generated_attributes = name ==&#34; t&#34;和generated_attributes或&#39;&#39;))文件&#34; /opt/odoo/openerp/addons/base/ir/ir_qweb.py",第297行, render_node result = self.render_element(element,template_attributes,generated_attributes,qwebcontext)文件 &#34; /opt/odoo/openerp/addons/base/ir/ir_qweb.py" ;,第320行,在 render_element generated_attributes = name ==&#34; t&#34;和generated_attributes或&#39;&#39;))文件&#34; /opt/odoo/openerp/addons/base/ir/ir_qweb.py",第297行, render_node result = self.render_element(element,template_attributes,generated_attributes,qwebcontext)文件 &#34; /opt/odoo/openerp/addons/base/ir/ir_qweb.py" ;,第320行,在 render_element generated_attributes = name ==&#34; t&#34;和generated_attributes或&#39;&#39;))文件&#34; /opt/odoo/openerp/addons/base/ir/ir_qweb.py",第297行, render_node result = self.render_element(element,template_attributes,generated_attributes,qwebcontext)文件 &#34; /opt/odoo/openerp/addons/base/ir/ir_qweb.py" ;,第320行,在 render_element generated_attributes = name ==&#34; t&#34;和generated_attributes或&#39;&#39;))文件&#34; /opt/odoo/openerp/addons/base/ir/ir_qweb.py",第297行, render_node result = self.render_element(element,template_attributes,generated_attributes,qwebcontext)文件 &#34; /opt/odoo/openerp/addons/base/ir/ir_qweb.py" ;,第325行,在 render_element raise_qweb_exception(message =&#34;无法呈现元素%r&#34;%element.tag,node = element,template = template)文件 &#34; /opt/odoo/openerp/addons/base/ir/ir_qweb.py" ;,第320行,在 render_element generated_attributes = name ==&#34; t&#34;和generated_attributes或&#39;&#39;))文件&#34; /opt/odoo/openerp/addons/base/ir/ir_qweb.py",第295行, render_node result = self._render_tag [t_render](self,element,template_attributes,generated_attributes,qwebcontext)文件 &#34; /opt/odoo/openerp/addons/base/ir/ir_qweb.py" ;,第503行,在 render_tag_field field = record._fields [field_name] QWebException:&#39; NoneType&#39;对象没有属性&#39; _fields&#39;
QWeb:
Could not render element 'div' The error occured while rendering the template 900
<div class="input-group">
<div t-field="odss_sale_order.order_date"/></div>
问题是什么,我该如何解决?
提前致谢, Hamza Tahboub
答案 0 :(得分:-1)
您是否尝试过将此行添加到PY文件的顶部。
from openerp import models, fields, api, _
希望这会解决它。
谢谢, 月光。