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

No conversion for undefined on selection field - Odoo v9 community

我在 Odoov9 社区的模块上有一个 select离子场

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

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',)

发票视图定义:

<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)

第二次编辑

这是表单视图中给我错误的实际字段,每次我单击 select 一个文档:

  <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 用于普通视图定义(公式、树、搜索等)。

  2. 您不能在普通视图字段定义中使用点符号。

因此,首先在您的视图所针对的模型上创建一个相关的 Char 字段。然后在视图中定义一个简单的字段即可。

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

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>