gpt4 book ai didi

javascript - 选择字段上的未定义没有转换 - Odoo v9 社区

转载 作者:行者123 更新时间:2023-12-03 06:13:25 30 4
gpt4 key购买 nike

我在 Odoov9 社区模块上有一个选择字段

但是,每次我点击它,选择一个记录时,它都会抛出这个错误:

Error: No conversion for undefined

http://localhost:8070/web/static/src/js/framework/pyeval.js:732
Traceback:
wrap@http://localhost:8070/web/static/src/js/framework/pyeval.js:732:29
wrapping_list<.__getitem__@http://localhost:8070/web/static/src/js/framework/pyeval.js:787:16
py.PY_getItem@http://localhost:8070/web/static/lib/py.js/lib/py.js:610:19
py.evaluate@http://localhost:8070/web/static/lib/py.js/lib/py.js:1403:24
py.evaluate@http://localhost:8070/web/static/lib/py.js/lib/py.js:1404:21
py.evaluate@http://localhost:8070/web/static/lib/py.js/lib/py.js:1397:35
py.evaluate@http://localhost:8070/web/static/lib/py.js/lib/py.js:1409:34
py.eval@http://localhost:8070/web/static/lib/py.js/lib/py.js:1453:16
eval_domains/<@http://localhost:8070/web/static/src/js/framework/pyeval.js:862:32
_.forEach@http://localhost:8070/web/static/lib/underscore/underscore.js:145:9
_.mixin/</_.prototype[name]@http://localhost:8070/web/static/lib/underscore/underscore.js:1484:29
eval_domains@http://localhost:8070/web/static/src/js/framework/pyeval.js:853:5
eval_domains/<@http://localhost:8070/web/static/src/js/framework/pyeval.js:867:32
_.forEach@http://localhost:8070/web/static/lib/underscore/underscore.js:145:9
_.mixin/</_.prototype[name]@http://localhost:8070/web/static/lib/underscore/underscore.js:1484:29
eval_domains@http://localhost:8070/web/static/src/js/framework/pyeval.js:853:5
eval_domains/<@http://localhost:8070/web/static/src/js/framework/pyeval.js:867:32
_.forEach@http://localhost:8070/web/static/lib/underscore/underscore.js:145:9
_.mixin/</_.prototype[name]@http://localhost:8070/web/static/lib/underscore/underscore.js:1484:29
eval_domains@http://localhost:8070/web/static/src/js/framework/pyeval.js:853:5
pyeval@http://localhost:8070/web/static/src/js/framework/pyeval.js:946:16
eval_arg@http://localhost:8070/web/static/src/js/framework/pyeval.js:957:16
ensure_evaluated@http://localhost:8070/web/static/src/js/framework/pyeval.js:980:21
.call@http://localhost:8070/web/static/src/js/framework/data_model.js:56:9
DataSet<.name_search@http://localhost:8070/web/static/src/js/framework/data.js:537:16
CompletionFieldMixin.get_search_result@http://localhost:8070/web/static/src/js/views/form_common.js:192:33
FieldMany2One<.render_editable/<.source@http://localhost:8070/web/static/src/js/views/form_relational_widgets.js:271:17
._search@http://localhost:8070/web/static/lib/jquery.ui/jquery-ui.js:7404:3
$.widget/</proxiedPrototype[prop]</<@http://localhost:8070/web/static/lib/jquery.ui/jquery-ui.js:415:19
.search@http://localhost:8070/web/static/lib/jquery.ui/jquery-ui.js:7396:10
$.widget/</proxiedPrototype[prop]</<@http://localhost:8070/web/static/lib/jquery.ui/jquery-ui.js:415:19
$.widget.bridge/$.fn[name]/<@http://localhost:8070/web/static/lib/jquery.ui/jquery-ui.js:513:19
.each@http://localhost:8070/web/static/lib/jquery/jquery.js:383:49
jQuery.prototype.each@http://localhost:8070/web/static/lib/jquery/jquery.js:136:24
$.widget.bridge/$.fn[name]@http://localhost:8070/web/static/lib/jquery.ui/jquery-ui.js:499:4
FieldMany2One<.render_editable/<@http://localhost:8070/web/static/src/js/views/form_relational_widgets.js:189:21
jQuery.event.dispatch@http://localhost:8070/web/static/lib/jquery/jquery.js:4640:50
jQuery.event.add/elemData.handle@http://localhost:8070/web/static/lib/jquery/jquery.js:4309:41

我不喜欢 Odoo 的新 javascript 库,所以,我不知道从哪里开始寻找这个,以前有人遇到过这种情况吗?

提前致谢!

编辑

这是发票模型代码(我从中调用它):

class account_move_line(models.Model):
_inherit = "account.move.line"

document_class_id = new_fields.Many2one(
'sii.document_class',
'Document Type',
related='move_id.document_class_id',
store=True,
readonly=True,
)
document_number = new_fields.Char(
string='Document Number',
related='move_id.document_number',
store=True,
readonly=True,
)


class account_journal_sii_document_class(models.Model):
_name = "account.journal.sii_document_class"
_description = "Journal SII Documents"

def name_get(self, cr, uid, ids, context=None):
result = []
for record in self.browse(cr, uid, ids, context=context):
result.append((record.id, record.sii_document_class_id.name))
return result

_order = 'journal_id desc, sequence, id'

sii_document_class_id = new_fields.Many2one('sii.document_class',
'Document Type', required=True)
sequence_id = new_fields.Many2one(
'ir.sequence', 'Entry Sequence', required=False,
help="""This field contains the information related to the numbering \
of the documents entries of this document type.""")
journal_id = new_fields.Many2one(
'account.journal', 'Journal', required=True)
sequence = new_fields.Integer('Sequence',)

发票 View 定义:

<xpath expr="//group[last()]" position="inside">
<filter string="Document Type" icon="terp-folder-orange" domain="[]" context="{'group_by':'sii_document_class_id'}"/>
</xpath>

document_type 模型本身:

class sii_document_class(models.Model):
_name = 'sii.document_class'
_description = 'SII Document Class'

name = fields.Char(
'Name', size=120)
doc_code_prefix = fields.Char(
'Document Code Prefix', help="Prefix for Documents Codes on Invoices \
and Account Moves. For eg. 'FAC' will build 'FAC 00001' Document Number")
code_template = fields.Char(
'Code Template for Journal')
sii_code = fields.Integer(
'SII Code', required=True)
document_letter_id = fields.Many2one(
'sii.document_letter', 'Document Letter')
report_name = fields.Char(
'Name on Reports',
help='Name that will be printed in reports, for example "CREDIT NOTE"')
document_type = fields.Selection(
[
('invoice', 'Invoices'),
('invoice_in', 'Purchase Invoices'),
('debit_note', 'Debit Notes'),
('credit_note', 'Credit Notes'),
('other_document', 'Other Documents')
],
string='Document Type',
help='It defines some behaviours on automatic journal selection and\
in menus where it is shown.')
active = fields.Boolean(
'Active', default=True)
dte = fields.Boolean(
'DTE', required=True)

第二次编辑

这是表单 View 中的实际字段,每次我单击选择一个文档时都会出现错误:

  <h6 style="color:red;text-align:center;text-transform:uppercase;font-weight:900">
<span t-field="o.journal_document_class_id.sii_document_class_id.name"/>
</h6>

最佳答案

  1. 您不能将 QWeb 用于普通 View 定义(公式、树、搜索等)。

  2. 您不能在普通 View 字段定义上使用点符号。

因此,首先在您的 View 所属的模型上创建一个相关的 Char 字段。然后只需在 View 中定义一个简单的字段即可。

示例(接近上面的代码):

class my_model(models.Model):
_name = 'my.model'

journal_document_class_id = fields.Many2one(
comodel_name="journal.document.class", string="Journal Doc Class")
# related field
sii_document_name = fields.Char(
string="Sii Document Name",
related="journal_document_class_id.sii_document_class_id.name")
<h6 style="color:red;text-align:center;text-transform:uppercase;font-weight:900">
<field name="sii_document_name"/>
</h6>

关于javascript - 选择字段上的未定义没有转换 - Odoo v9 社区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39217313/

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