Dalam mengembangkan aplikasi berbasis Odoo 17 ini kita biasanya akan membagi pengguna sesuai peranannya. Di siniliah maka kita akan membuat security group.
Security group pada pengembangan aplikasi Odoo 17 adalah seperti pada langkah-langkah berikut ini
- Membuat struktur awal file
$ pwd /home/apku/odooku/addons/asramaku $ mkdir security $ touch security/hostel_security.xml $ touch security/ir.model.access.csv $ chmod -R a+rx security
- Mendefinisikan group dalam XML
Catatan gambar: folder asrama direname ke asramaku<?xml version="1.0" encoding="utf-8"?> <odoo> <record id="module_category_hostel" model="ir.module.category"> <field name="name">Pengelolaan Hostel</field> <field name="sequence">31</field> </record> <record id="group_hostel_manager" model="res.groups"> <field name="name">Manajer Hostel</field> <field name="category_id" ref="module_category_hostel"/> <field name="users" eval="[(4, ref('base.user_root')),(4, ref('base.user_admin'))]"/> </record> <record id="group_hostel_user" model="res.groups"> <field name="name">Pengguna Hostel</field> <field name="category_id" ref="module_category_hostel"/> </record> </odoo>
Pembahasan mengenail eval silahkan mengunjungi
https://www.odoo.com/forum/help-1/what-does-that-number-represents-in-eval-like-3-4-5-6-243997 dan
https://www.odoo.com/forum/help-1/what-is-the-meaning-of-the-4-in-the-expression-eval-4-ref-base-group-user-84907 .
- Model Access dalam CSV
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink access_hostel_manager_id,access.hostel.manager,asramaku.model_asrama_hostel,group_hostel_manager,1,1,1,1 access_hostel_user_id,access.hostel.user,asramaku.model_asrama_hostel,group_hostel_user,1,0,0,0
- File Manifest
{ 'name': 'Manajemen Asrama', "data":[ "security/hostel_security.xml", "security/ir.model.access.csv", ], }
- Modul ir.module.category
https://github.com/odoo/odoo/blob/17.0/odoo/addons/base/models/ir_module.py .
- Modul res.groups
https://github.com/odoo/odoo/blob/17.0/odoo/addons/base/models/res_users.py
- Modul base
https://github.com/odoo/odoo/blob/17.0/odoo/addons/base/data/base_data.sql
https://github.com/odoo/odoo/blob/17.0/odoo/addons/base/models/res_users.py .
- Class base
https://github.com/odoo/odoo/blob/17.0/odoo/addons/base/models/ir_model.py .
- Restart odoo
# docker restart odooku-web-1
- Activate developer mode
- Update app list
- Activate modul
- Update pada model
- Melihat group
- Melihat Access Rights
- Melihat User- Access Rights
- External Identifiers
- Melihat ke PostgreSQL
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 id,name,sequence from ir_module_category where id=97; id | name | sequence ----+---------------------------------+---------- 97 | {"en_US": "Pengelolaan Hostel"} | 31 (1 row) rnd.metiu.co.id=# select id, name, category_id from res_groups where id=24 or id=25; id | name | category_id ----+------------------------------+------------- 13 | {"en_US": "Pengguna Hostel"} | 97 12 | {"en_US": "Manajer Hostel"} | 97 (2 rows)
Informasi lebih lanjut silahkan mengunjungi
1. https://www.postgresql.org/docs/current/datatype-json.html .
2. https://www.odoo.com/documentation/17.0/developer/tutorials/server_framework_101/04_securityintro.html .
Kunjungi www.proweb.co.id/implementasi-odoo/ untuk menambah wawasan implementasi Odoo ERP.