Reputation: 3897
I have a selection field on a module for Odoov9 Community
But, everytime, I click on it, to select a record it throws me this error:
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
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?
Thanks in advance!
EDIT
This is the invoice model code(where I'm calling it from):
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',)
The invoice view definitions:
<xpath expr="//group[last()]" position="inside">
<filter string="Document Type" icon="terp-folder-orange" domain="[]" context="{'group_by':'sii_document_class_id'}"/>
</xpath>
The document_type model itself:
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)
SECOND EDIT
This is the actual field in the form view which is giving me the error, everytime I click to select one document:
<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>
Upvotes: 0
Views: 885
Reputation: 14778
You can't use QWeb for normal view definitions (formular, tree, search, etc.).
You can't use dot-notation on normal view field definitions.
So first off create a related Char
field on the model your view is for. Then just define a simple field in the view.
Example (close to your code above):
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>
Upvotes: 1