so i'm in a training, and i got task to create some custom module, it works well when the code still like this
models.py
class Kursus(models.Model):
_name = 'training.kursus'
name = fields.Char(string="Judul", required=True)
description = fields.Text()
class Sesi(models.Model):
_name = 'training.sesi'
name = fields.Char(required=True)
start_date = fields.Date()
duration = fields.Float(digits=(6, 2), help="Durasi Hari")
seats = fields.Integer(string="Jumlah Kursi")
instructor_id = fields.Many2one('res.partner', string="Instruktur")
and the view.xml is like this :
<odoo>
<data>
<!-- ### Membuat Tampilan Tree/List Sesi ### -->
<record model="ir.ui.view" id="sesi_tree_view">
<field name="name">training.sesi.tree</field>
<field name="model">training.sesi</field>
<field name="arch" type="xml">
<tree string="Sesi List">
<field name="name"/>
<field name="start_date"/>
<field name="duration"/>
<field name="seats"/>
<field name="instructor_id"/>
</tree>
</field>
</record>
<!-- ### Membuat Tampilan Form Sesi ### -->
<record model="ir.ui.view" id="sesi_form_view">
<field name="name">training.sesi.form</field>
<field name="model">training.sesi</field>
<field name="arch" type="xml">
<form string="Sesi Form">
<sheet>
<group>
<field name="name"/>
<field name="start_date"/>
<field name="duration"/>
<field name="seats"/>
<field name="instructor_id"/>
</group>
</sheet>
</form>
</field>
</record>
<!-- ### Membuat Action/Event Object Sesi ### -->
<record model="ir.actions.act_window" id="sesi_list_action">
<field name="name">Sesi</field>
<field name="res_model">training.sesi</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<!-- ### Membuat Sub Menu Sesi ### -->
<menuitem id="sesi_menu" name="Sesi" parent="training_odoo_menu" action="sesi_list_action"/>
</data>
</odoo>
but when i updated the models.py into like this, like my code below, it gain an error, the error is on the last of this question
class Kursus(models.Model):
_name = 'training.kursus'
name = fields.Char(string="Judul", required=True)
description = fields.Text()
session_ids = fields.One2many('training.sesi', 'course_id', string="Sesi")
class Sesi(models.Model):
_name = 'training.sesi'
name = fields.Char(required=True)
start_date = fields.Date()
duration = fields.Float(digits=(6, 2), help="Durasi Hari")
seats = fields.Integer(string="Jumlah Kursi")
instructor_id = fields.Many2one('res.partner', string="Instruktur")
course_id = fields.Many2one('training.kursus', ondelete='cascade', string="Kursus", required=True)
and the view.xml like this
<record model="ir.ui.view" id="kursus_form_view">
<field name="name">training.kursus.form</field>
<field name="model">training.kursus</field>
<field name="arch" type="xml">
<form string="Kursus Form">
<sheet>
<group>
<field name="name"/>
</group>
<notebook>
<page string="Keterangan">
<field name="description"/>
</page>
<page string="Sesi">
<field name="session_ids">
<tree string="Daftar Sesi">
<field name="name"/>
<field name="instructor_id"/>
</tree>
<form>
<group string="Informasi">
<field name="name"/>
<field name="instructor_id"/>
</group>
<group string="Jadwal">
<field name="start_date"/>
<field name="duration"/>
<field name="seats"/>
</group>
</form>
</field>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
<!-- ### Membuat Tampilan Tree/List Sesi ### -->
<record model="ir.ui.view" id="sesi_tree_view">
<field name="name">training.sesi.tree</field>
<field name="model">training.sesi</field>
<field name="arch" type="xml">
<tree string="Sesi List">
<field name="name"/>
<field name="course_id"/>
<field name="start_date"/>
<field name="duration"/>
<field name="seats"/>
<field name="instructor_id"/>
</tree>
</field>
</record>
<!-- ### Membuat Tampilan Form Sesi ### -->
<record model="ir.ui.view" id="sesi_form_view">
<field name="name">training.sesi.form</field>
<field name="model">training.sesi</field>
<field name="arch" type="xml">
<form string="Sesi Form">
<sheet>
<group>
<group string="Informasi">
<field name="course_id"/>
<field name="name"/>
<field name="instructor_id"/>
</group>
<group string="Jadwal">
<field name="start_date"/>
<field name="duration"/>
<field name="seats"/>
</group>
</group>
</sheet>
</form>
</field>
</record>
<!-- ### Membuat Action/Event Object Sesi ### -->
<record model="ir.actions.act_window" id="sesi_list_action">
<field name="name">Sesi</field>
<field name="res_model">training.sesi</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<!-- ### Membuat Sub Menu Sesi ### -->
<menuitem id="sesi_menu" name="Sesi" parent="training_odoo_menu" action="sesi_list_action"/>
</data>
</odoo>
i got this error when i upgraded module in odoo
Error:
Odoo Server Error
Traceback (most recent call last):
File "/home/fauz2n/odoo/odoo-12/odoo/tools/cache.py", line 88, in lookup
r = d[key]
File "/home/fauz2n/odoo/odoo-12/odoo/tools/func.py", line 69, in wrapper
return func(self, *args, **kwargs)
File "/home/fauz2n/odoo/odoo-12/odoo/tools/lru.py", line 44, in __getitem__
a = self.d[obj].me
KeyError: ('ir.model.data', <function IrModelData.xmlid_lookup at 0x7fec8f847d90>, 'training.training_odoo_menu')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/fauz2n/odoo/odoo-12/odoo/tools/convert.py", line 758, in parse
self._tags[rec.tag](rec, de, mode=mode)
File "/home/fauz2n/odoo/odoo-12/odoo/tools/convert.py", line 455, in _tag_menuitem
menu_parent_id = self.id_get(rec.get('parent',''))
File "/home/fauz2n/odoo/odoo-12/odoo/tools/convert.py", line 741, in id_get
res = self.model_id_get(id_str, raise_if_not_found)
File "/home/fauz2n/odoo/odoo-12/odoo/tools/convert.py", line 747, in model_id_get
return self.env['ir.model.data'].xmlid_to_res_model_res_id(id_str, raise_if_not_found=raise_if_not_found)
File "/home/fauz2n/odoo/addons/ORIGINAL12/base/models/ir_model.py", line 1404, in xmlid_to_res_model_res_id
return self.xmlid_lookup(xmlid)[1:3]
File "<decorator-gen-25>", line 2, in xmlid_lookup
File "/home/fauz2n/odoo/odoo-12/odoo/tools/cache.py", line 93, in lookup
value = d[key] = self.method(*args, **kwargs)
File "/home/fauz2n/odoo/addons/ORIGINAL12/base/models/ir_model.py", line 1393, in xmlid_lookup
raise ValueError('External ID not found in the system: %s' % xmlid)
ValueError: External ID not found in the system: training.training_odoo_menu
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/fauz2n/odoo/odoo-12/odoo/http.py", line 656, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/home/fauz2n/odoo/odoo-12/odoo/http.py", line 314, in _handle_exception
raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
File "/home/fauz2n/odoo/odoo-12/odoo/tools/pycompat.py", line 87, in reraise
raise value
File "/home/fauz2n/odoo/odoo-12/odoo/http.py", line 698, in dispatch
result = self._call_function(**self.params)
File "/home/fauz2n/odoo/odoo-12/odoo/http.py", line 346, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/home/fauz2n/odoo/odoo-12/odoo/service/model.py", line 97, in wrapper
return f(dbname, *args, **kwargs)
File "/home/fauz2n/odoo/odoo-12/odoo/http.py", line 339, in checked_call
result = self.endpoint(*a, **kw)
File "/home/fauz2n/odoo/odoo-12/odoo/http.py", line 941, in __call__
r