提问人:free94 提问时间:11/16/2023 最后编辑:free94 更新时间:11/20/2023 访问量:65
Odoo 16 - 继承:在服务台工单视图表单中添加按钮时遇到麻烦
Odoo 16 - Inheritance : trouble to add button in helpdesk ticket view form
问:
嗨,stackoverflow 社区!
我正在尝试在Odoo 16的帮助台工单视图的标题中添加一个按钮。
为此,我创建了一个专用模块,其中我有
-user:
-helpdesk_ticket_custo
-models
+ __init__.py
+ helpdesk_ticket_custo.py
-security
+ ir.model.access.csv
-views
+ helpdesk_ticket_custo_views.xml
+ __init__.py
+ __manifest__.py
我在更新我的 custo 模块时遇到错误
这是我的观点
<odoo>
<record id="inherited_helpdesk_ticket_custo_view_form" model="ir.ui.view">
<field name="name">helpdesk.ticket.custo.form</field>
<field name="model">helpdesk.ticket.custo</field>
<field name="inherit_id" ref="helpdesk.helpdesk_ticket_view_form"/>
<field name="arch" type="xml">
<xpath expr="//header" position="inside">
<button name="action_view_send_to_customer"
type="object"
class="oe_stat_button"
icon="fa-truck"
string="Renvoyer"
help="Create out-sav to send back product to customer"/>
</xpath>
</field>
</record>
</odoo>
- 我的观点说使用我的模型helpdesk.ticket.custo
- AND 说要从 helpdesk.ticket 继承,因为我想在现有视图中插入一个按钮
所以这是我的模型:
from odoo import fields,models
class Helpdesk_Ticket_Custo(models.Model):
_name = "helpdesk.ticket.custo"
_description = "Surcouche pour le module assistance"
__inherit = "helpdesk.ticket"
def action_view_send_to_customer(self):
print('succès!')
return
似乎很容易:/
但是我有这个错误:字段 stage_id
不存在
我不明白问题出在哪里
谢谢你的帮助...
我希望更新我的模块没有错误,并看到我的按钮被添加到helpdesk.ticket的现有视图中
整个堆栈跟踪
Traceback (most recent call last):
File "/home/odoo/src/odoo/odoo/http.py", line 1589, in _serve_db
return service_model.retrying(self._serve_ir_http, self.env)
File "/home/odoo/src/odoo/odoo/service/model.py", line 133, in retrying
result = func()
File "/home/odoo/src/odoo/odoo/http.py", line 1616, in _serve_ir_http
response = self.dispatcher.dispatch(rule.endpoint, args)
File "/home/odoo/src/odoo/odoo/http.py", line 1820, in dispatch
result = self.request.registry['ir.http']._dispatch(endpoint)
File "/home/odoo/src/odoo/odoo/addons/base/models/ir_http.py", line 154, in _dispatch
result = endpoint(**request.params)
File "/home/odoo/src/odoo/odoo/http.py", line 697, in route_wrapper
result = endpoint(self, *args, **params_ok)
File "/home/odoo/src/odoo/addons/web/controllers/dataset.py", line 46, in call_button
action = self._call_kw(model, method, args, kwargs)
File "/home/odoo/src/odoo/addons/web/controllers/dataset.py", line 33, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/home/odoo/src/odoo/odoo/api.py", line 466, in call_kw
result = _call_kw_multi(method, model, args, kwargs)
File "/home/odoo/src/odoo/odoo/api.py", line 453, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "<decorator-gen-76>", line 2, in button_immediate_install
File "/home/odoo/src/odoo/odoo/addons/base/models/ir_module.py", line 74, in check_and_log
return method(self, *args, **kwargs)
File "/home/odoo/src/odoo/odoo/addons/base/models/ir_module.py", line 468, in button_immediate_install
return self._button_immediate_function(type(self).button_install)
File "/home/odoo/src/odoo/odoo/addons/base/models/ir_module.py", line 592, in _button_immediate_function
registry = modules.registry.Registry.new(self._cr.dbname, update_module=True)
File "<decorator-gen-16>", line 2, in new
File "/home/odoo/src/odoo/odoo/tools/func.py", line 87, in locked
return func(inst, *args, **kwargs)
File "/home/odoo/src/odoo/odoo/modules/registry.py", line 90, in new
odoo.modules.load_modules(registry, force_demo, status, update_module)
File "/home/odoo/src/odoo/odoo/modules/loading.py", line 488, in load_modules
processed_modules += load_marked_modules(cr, graph,
File "/home/odoo/src/odoo/odoo/modules/loading.py", line 372, in load_marked_modules
loaded, processed = load_module_graph(
File "/home/odoo/src/odoo/odoo/modules/loading.py", line 231, in load_module_graph
load_data(cr, idref, mode, kind='data', package=package)
File "/home/odoo/src/odoo/odoo/modules/loading.py", line 71, in load_data
tools.convert_file(cr, package.name, filename, idref, mode, noupdate, kind)
File "/home/odoo/src/odoo/odoo/tools/convert.py", line 763, in convert_file
convert_xml_import(cr, module, fp, idref, mode, noupdate)
File "/home/odoo/src/odoo/odoo/tools/convert.py", line 829, in convert_xml_import
obj.parse(doc.getroot())
File "/home/odoo/src/odoo/odoo/tools/convert.py", line 749, in parse
self._tag_root(de)
File "/home/odoo/src/odoo/odoo/tools/convert.py", line 709, in _tag_root
raise ParseError(msg) from None # Restart with "--log-handler odoo.tools.convert:DEBUG" for complete traceback
odoo.tools.convert.ParseError: while parsing /home/odoo/src/user/helpdesk_ticket_custo/views/helpdesk_ticket_views.xml:3
Error while validating view near:
<form string="Helpdesk Ticket">
<header>
<button name="assign_ticket_to_self" string="Assign To Me" type="object" class="oe_highlight" groups="helpdesk.group_helpdesk_user" attrs="{'invisible': [('user_id', '!=', False)]}" data-hotkey="q"/>
Field `use_credit_notes` does not exist
View error context:
{'file': '/home/odoo/src/user/helpdesk_ticket_custo/views/helpdesk_ticket_views.xml',
'line': 1,
'name': 'helpdesk.ticket.custo.form',
'view': ir.ui.view(1900,),
'view.model': 'helpdesk_ticket_custo',
'view.parent': ir.ui.view(1184,),
'xmlid': 'inherited_helpdesk_ticket_view_form'}
The above server error caused the following client error:
RPC_ERROR: Odoo Server Error
at makeErrorFromResponse (https://<...>.odoo.com/web/assets/541-67840bc/web.assets_backend.min.js:995:163)
at XMLHttpRequest.<anonymous> (https://<...>.dev.odoo.com/web/assets/541-67840bc/web.assets_backend.min.js:1003:13)
解决
- _inherit,而不是__inherit两者都_inheritS
- no name 属性
class HelpdeskTicket(models.Model):
_inherit = "helpdesk.ticket"
def action_view_send_to_customer(self):
print("Bien joué")
答:
0赞
sylvain
11/17/2023
#1
Error-Traceback 只是告诉我们:
如果您的视图 (, view-id=1900)
包含字段 ',
那不在其相关模型中,
你只是得到这样的错误:'helpdesk.ticket.custo.form'
'use_credit_notes
'helpdesk_ticket_custo'
odoo.tools.convert.ParseError: while parsing
/home/odoo/src/user/helpdesk_ticket_custo/views/helpdesk_ticket_views.xml:3
Error while validating view near:
<form string="Helpdesk Ticket">
<header>
<button name="assign_ticket_to_self" string="Assign To Me" type="object"
class="oe_highlight" groups="helpdesk.group_helpdesk_user"
attrs="{'invisible': [('user_id', '!=', False)]}" data-hotkey="q"/>
Field `use_credit_notes` does not exist
View error context:
{'file': '/home/odoo/src/user/helpdesk_ticket_custo/views/helpdesk_ticket_views.xml',
'line': 1,
'name': 'helpdesk.ticket.custo.form',
'view': ir.ui.view(1900,),
'view.model': 'helpdesk_ticket_custo',
'view.parent': ir.ui.view(1184,),
'xmlid': 'inherited_helpdesk_ticket_view_form'}
即您需要另一个模型的字段的值,您可以使用模型中的 Many2One 字段关联这两个模型'helpdesk_ticket_custo'
评论
0赞
free94
11/17/2023
感谢您抽出宝贵时间接受采访!我理解你的意思,但是,正如你所看到的,在我的观点或我的模型中,我都没有“use_credit_notes”字段:(
1赞
Kenly
11/18/2023
#2
发生这种情况是因为新模型不继承自 ,您使用了 ,而不是属性helpdesk.ticket.custo
helpdesk.ticket
__inherit
_inherit
评论
0赞
free94
11/20/2023
非常感谢,在很多地方,单个字符可以改变整个行为..inherit vs inheritS,我在这个中添加了一个错误......
评论