Pembahasan mengenai pemrograman Odoo 17 sampai kepada pembuatan menu item dan action. Di sini kita akan membuat action, membuat menu item yang memanggil action, mengupgrade modul dengan hasil tambahan menu lengkap dengan default tampilan list view, tampilan form, tampilan search dan group by.
Langkah-langkah pemrograman menu item dan action pada Odoo 17 adalah seperti pada langkah-langkah berikut ini
- Menyiapkan file
12345
$ pwd
/home/apku/odooku/addons/asramaku
$
mkdir
views
$ touch views/hostel.xml
$
chmod
-R a+rx views
- Pembuatan view
Catatan gambar: folder asrama direname ke asramaku1234567891011121314151617<?xml version=
"1.0"
encoding=
"utf-8"
?>
<odoo>
<record id=
"action_hostel"
model=
"ir.actions.act_window"
>
<field name=
"name"
>Hostel</field>
<field name=
"type"
>ir.actions.act_window</field>
<field name=
"res_model"
>asrama.hostel</field>
<field name=
"view_mode"
>tree,form</field>
<field name=
"help"
type=
"html"
>
<p
class
=
"oe_view_nocontent_create"
>
Membuat Hostel.
</p>
</field>
</record>
<menuitem id=
"hostel_main_menu"
name=
"Hostel"
sequence=
"1"
/>
<menuitem id=
"hostel_type_menu"
name=
"Hostel"
parent=
"hostel_main_menu"
action=
"action_hostel"
groups=
"group_hostel_manager"
sequence=
"1"
/>
</odoo>
- Update pada manifest
123456789{
'name'
:
'Manajemen Asrama'
,
"summary"
:
"Cara mudah kelola asrama"
,
"data"
:[
"security/hostel_security.xml"
,
"security/ir.model.access.csv"
,
"views/hostel.xml"
,
],
}
- Restart Odoo
1
# docker restart odooku-web-1
- Activate Developer Mode
- Update app list
- Upgrade modul
- Tampilan list view
- Tampilan form
- Tampilan search
- Tampilan group by
- Technical | Action
- Technical | Menu Items
- Groups Menu
- Technical – External Identifier
- Akses ke PostgreSQL
12345678910111213141516
root@odoo17:/home/aris# docker
exec
-it odooku-db-1 bash
root@f28c3368476e:/# psql -U odoo -d rnd.metiu.co.id
psql (15.6 (Debian 15.6-1.pgdg120+2))
Type
"help"
for
help.
rnd.metiu.co.id=# select name, res_model,help from ir_act_window where id=87;
name | res_model | help
---------------------+---------------+------------------------------------------------------------------------------------------------------
{
"en_US"
:
"Hostel"
} | asrama.hostel | {
"en_US"
:
"<p class=\"oe_view_nocontent_create\">\n Membuat Hostel.\n </p>\n "
}
(1 row)
rnd.metiu.co.id=# select id, name, action, parent_path from ir_ui_menu where id=70 OR id=71 ;
id | name | action | parent_path
----+---------------------+--------------------------+-------------
70 | {
"en_US"
:
"Hostel"
} | | 70/
71 | {
"en_US"
:
"Hostel"
} | ir.actions.act_window,87 | 70/71/
Informasi terkait artikel ini:
1. https://www.odoo.com/documentation/17.0/developer/reference/backend/actions.html .
2. https://github.com/odoo/odoo/blob/17.0/odoo/addons/base/models/ir_ui_menu.py line 20 .
3. https://github.com/odoo/odoo/blob/17.0/odoo/addons/base/models/ir_actions.py line 224
Kunjungi www.proweb.co.id/implementasi-odoo/ untuk menambah wawasan implementasi Odoo ERP.