PT Proweb Indonesia
The City Tower Level 12 Unit 1-N, Jakarta Pusat

Pembatasan Akses Field Table Dalam Pengembangan Aplikasi Berbasis Odoo

Jun 5, 2026 | Odoo 17 Development

Ketika kita melakukan pengembangan aplikasi berbasis Odoo kita mungkin ingin membatasi akses ke field database ke group tertentu.

Pembatasan akses ke field table dalam pengembangan aplikasi berbasis Odoo adalah seperti pada langkah-langkah berikut ini

  1. Start SSH file system
  2. Model

    from odoo import fields, models
    
    class Motel(models.Model):
        _name = 'motel.motel'
        _description = 'Informasi tentang motel'
    
        name = fields.Char(string='Nama Motel',required=True)
        hostel_code = fields.Char(string='Code',required=True)
    
        street = fields.Char('Jalan')
        street2 = fields.Char('Jalan2')
    
        is_public = fields.Boolean(groups='motelku.group_motel_manager')
        notes = fields.Text(groups='motelku.group_motel_manager')
    
  3. View

    <?xml version="1.0" encoding="utf-8"?>
    <odoo>
    
        <!-- motel.motel form view -->
        <record id="motel_motel_view_form" model="ir.ui.view">
            <field name="name">Form Motel</field>
            <field name="model">motel.motel</field>
            <field name="arch" type="xml">
                <form string="">
                    <sheet>
                        <group>
                            <!-- Add your fields here -->
                            <group>
                                <field name="name" />
                                <field name="hostel_code" />
                                <field name="street" />
                                <field name="street2" />
                            </group>
                            <group>
                                <field name="is_public" />
                                <field name="notes" />
                            </group>                        
                        </group>
                    </sheet>
                </form>
            </field>
        </record>
    
        <!-- motel.motel action window -->
        <record id="motel_motel_action" model="ir.actions.act_window">
            <field name="name">Motel</field>
            <field name="res_model">motel.motel</field>
            <field name="view_mode">tree,form</field>
        </record>
    
        <menuitem id="motel_main_menu" name="Motel" sequence="1"/>
        <menuitem id="motel_menu" name="Hostel" 
            parent="motel_main_menu" action="motel_motel_action" 
            sequence="10"/>
    </odoo>
    
  4. Manifest

    # -*- coding: utf-8 -*-
    {
        'name': "motelku",
        'summary': "Motel Mgmt",
        'description': """
    Manajemen motel yang mudah
        """,
        'author': "PT Proweb",
        'website': "https://www.proweb.co.id",
    
        # any module necessary for this one to work correctly
        'depends': ['base'],
    
        # always loaded
        'data': [
            'security/groups.xml',
            'security/ir.model.access.csv',
            'views/motel.xml',
            #'views/templates.xml',
        ],
        # only loaded in demonstration mode
        #'demo': [
        #    'demo/demo.xml',
        #],
        'installable': True,
    }
    
  5. Start SSH dan update modul

  6. Tampilan manager
  7. Tampilan user

Kunjungi https://www.proweb.co.id/implementasi-odoo/ untuk menambah wawasan anda mengenai Odoo ERP.