gpt4 book ai didi

python - Odoo 按钮单击打开弹出窗口和其中的文本

转载 作者:太空宇宙 更新时间:2023-11-03 15:27:01 29 4
gpt4 key购买 nike

我的 Odoo 工作流程带有“取消”和“重置”按钮。我需要用户点击这些按钮可以添加一个原因。

为此,我找到了 sale_cancel_reason 应用程序。示例如下:enter image description here

但我每次都需要写新的原因,而不是从列表中选择。我绑定(bind)了与向导的many2one关系,用户每次都可以在弹出的向导窗口上写下原因:

cancel_id = fields.Many2one('sale.order.cancel', string="Cancellation")

'sale.order.cancel' - 向导对象

但是后来我得到了错误:

Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py", line 177, in run_wsgi
execute(self.server.app)
File "/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py", line 165, in execute
application_iter = app(environ, start_response)
File "/opt/odoo/openerp/service/server.py", line 245, in app
return self.app(e, s)
File "/opt/odoo/openerp/service/wsgi_server.py", line 184, in application
return application_unproxied(environ, start_response)
File "/opt/odoo/openerp/service/wsgi_server.py", line 170, in application_unproxied
result = handler(environ, start_response)
File "/opt/odoo/openerp/http.py", line 1488, in __call__
return self.dispatch(environ, start_response)
File "/opt/odoo/openerp/http.py", line 1462, in __call__
return self.app(environ, start_wrapped)
File "/usr/local/lib/python2.7/dist-packages/werkzeug/wsgi.py", line 588, in __call__
return self.app(environ, start_response)
File "/opt/odoo/openerp/http.py", line 1637, in dispatch
ir_http = request.registry['ir.http']
File "/opt/odoo/openerp/http.py", line 360, in registry
return openerp.modules.registry.RegistryManager.get(self.db) if self.db else None
File "/opt/odoo/openerp/modules/registry.py", line 354, in get
update_module)
File "/opt/odoo/openerp/modules/registry.py", line 385, in new
openerp.modules.load_modules(registry._db, force_demo, status, update_module)
File "/opt/odoo/openerp/modules/loading.py", line 334, in load_modules
force, status, report, loaded_modules, update_module)
File "/opt/odoo/openerp/modules/loading.py", line 237, in load_marked_modules
loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)
File "/opt/odoo/openerp/modules/loading.py", line 137, in load_module_graph
init_module_models(cr, package.name, models)
File "/opt/odoo/openerp/modules/module.py", line 293, in init_module_models
result = obj._auto_init(cr, {'module': module_name})
File "/opt/odoo/openerp/api.py", line 238, in wrapper
return old_api(self, *args, **kwargs)
File "/opt/odoo/openerp/models.py", line 2625, in _auto_init
self._m2o_fix_foreign_key(cr, self._table, k, dest_model, f.ondelete)
File "/opt/odoo/openerp/api.py", line 238, in wrapper
return old_api(self, *args, **kwargs)
File "/opt/odoo/openerp/models.py", line 2384, in _m2o_fix_foreign_key
self._m2o_add_foreign_key_checked(source_field, dest_model, ondelete)
File "/opt/odoo/openerp/models.py", line 2324, in _m2o_add_foreign_key_checked
'Many2One relationships from non-transient Model to TransientModel are forbidden'
AssertionError: Many2One relationships from non-transient Model to TransientModel are forbidden

据我了解,我无法将 Many2one 关系与 wizzard 对象一起使用。但是我还能如何制作带有可写原因字段的弹出窗口呢?有什么办法可以做到这一点吗?

最佳答案

编辑sale_cancel_reason\wizard\cancel_reason_view.xml 文件并更改:

<field name="reason_id" widget="selection"/>

<field name="reason_id"/>

更新:

要在每次单击取消按钮时创建新原因,请使用此 sale_cancel_reason

changed reason_id (Many2one) to reason (Char)

关于python - Odoo 按钮单击打开弹出窗口和其中的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43061847/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com