Security Group pada Pengembangan Aplikasi Odoo 17

Jul 1, 2024 | Odoo 17 Development

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

  1. 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
    
  2. 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 .

  3. 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
    
  4. File Manifest

    {
        'name': 'Manajemen Asrama',
        "data":[
            "security/hostel_security.xml",
            "security/ir.model.access.csv",
        ],
    }
    
  5. Modul ir.module.category
    https://github.com/odoo/odoo/blob/17.0/odoo/addons/base/models/ir_module.py .

  6. Modul res.groups
    https://github.com/odoo/odoo/blob/17.0/odoo/addons/base/models/res_users.py

  7. 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 .

  8. Class base
    https://github.com/odoo/odoo/blob/17.0/odoo/addons/base/models/ir_model.py .

  9. Restart odoo
    # docker restart odooku-web-1
    
  10. Activate developer mode

  11. Update app list

  12. Activate modul

  13. Update pada model


  14. Melihat group



  15. Melihat Access Rights


  16. Melihat User- Access Rights

  17. External Identifiers


  18. 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 https://www.postgresql.org/docs/current/datatype-json.html .

Kunjungi www.proweb.co.id/implementasi-odoo/ untuk menambah wawasan implementasi Odoo ERP.