No conversion for undefined on selection field - Odoo v9 community
<p>I have a selection field on a module for Odoov9 Community</p>

<p>But, everytime, I click on it, to select a record it throws me this error:</p>

<pre><code>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&lt;.__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/&lt;@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/&lt;/_.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/&lt;@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/&lt;/_.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/&lt;@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/&lt;/_.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&lt;.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&lt;.render_editable/&lt;.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/&lt;/proxiedPrototype[prop]&lt;/&lt;@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/&lt;/proxiedPrototype[prop]&lt;/&lt;@http://localhost:8070/web/static/lib/jquery.ui/jquery-ui.js:415:19
$.widget.bridge/$.fn[name]/&lt;@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&lt;.render_editable/&lt;@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
</code></pre>

<p>I'm not fond on new javascript libraries for Odoo, so, I don't know where to start looking for this, has this happened to anyone before?</p>

<p>Thanks in advance!</p>

<p><strong>EDIT</strong></p>

<p>This is the invoice model code(where I'm calling it from):</p>

<pre><code>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',)
</code></pre>

<p>The invoice view definitions:</p>

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

<p>The document_type model itself:</p>

<pre><code>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)
</code></pre>

<p><strong>SECOND EDIT</strong></p>

<p>This is the actual field in the form view which is giving me the error, everytime I click to select one document:</p>

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

<ol>
<li><p>You can't use QWeb for normal view definitions (formular, tree, search, etc.).</p></li>
<li><p>You can't use dot-notation on normal view field definitions.</p></li>
</ol>

<p>So first off create a related <code>Char</code> field on the model your view is for. Then just define a simple field in the view.</p>

<p>Example (close to your code above):</p>

<pre class="lang-py prettyprint-override"><code>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")
</code></pre>

<pre class="lang-xml prettyprint-override"><code>&lt;h6 style="color:red;text-align:center;text-transform:uppercase;font-weight:900"&gt;
    &lt;field name="sii_document_name"/&gt;
&lt;/h6&gt;
</code></pre>

javascript python openerp odoo-9