Dalam melakukan pengembangan aplikasi Odoo 17 kita mungkin membutuhkan standarisasi keakuratan desimal. Keakuratan desimal ini kemudian diterapkan ke field-field yang membutuhkan.
Decimal accuracy pada pengembangan Odoo 17 adalah seperti pada penjelasan-penjelasan berikut ini
- Form sebelumnya
- Aktifkan developer mode dengan Odoo Debug
- Decimal accuracy bawaan Odoo
- Tambah data.xml
<?xml version="1.0" encoding="utf-8"?> <odoo> <data noupdate="1"> <!-- Precisions --> <record forcecreate="True" id="decimal_point" model="decimal.precision"> <field name="name">Nilai Rating</field> <field name="digits">3</field> </record> </data> </odoo>
- Update model
from odoo import api, fields, models class Hostel(models.Model): _name = 'asrama.hostel' _description = "Informasi tentang asrama-hostel" _order = "id desc, name" _rec_name = 'hostel_code' name = fields.Char(string="Nama Hostel",required=True) hostel_code = fields.Char(string="Kode",required=True) street = fields.Char('Jalan') street2 = fields.Char('Jalan2') zip = fields.Char('Zip', change_default=True) city = fields.Char('Kota') state_id = fields.Many2one('res.country.state',string="State") country_id = fields.Many2one('res.country', string='Negara') phone = fields.Char('Phone',required=True) mobile = fields.Char('Mobile',required=True) email = fields.Char('Email') hostel_floors = fields.Integer(string="Jml Lantai") image = fields.Binary('Gambar Hostel') active = fields.Boolean("Active", default=True, help="Akfikan/Nonaktifkan data hostel") type = fields.Selection([("male","Laki-laki"),("female","Perempuan"),("common","Umum")],"Tipe", help="Tipe Hostel", required=True, default="common") other_info = fields.Text("Informasi lain",help="Masukkan informasi lain") description = fields.Html("Description") hostel_rating = fields.Float("Rata-rata Rating Hostel",digits='Nilai Rating') @api.depends('hostel_code') def _compute_display_name(self): for record in self: name = record.name if record.hostel_code: name = f'{name} ({record.hostel_code})' record.display_name = name
- Update manifest
{ 'name': 'Manajemen Asrama', "summary": "Cara mudah kelola asrama", "data":[ "security/hostel_security.xml", "security/ir.model.access.csv", "data/data.xml", "views/hostel.xml", ], }
- Restart Odoo
# /home/apku/odooku/addons/asramaku# chmod -R a+rx data # docker restart odooku-web-1
- Upgrade modul
- Pilhan akurasi desimal baru
- Penerapan akurasi desimal ke field
Kunjungi www.proweb.co.id/implementasi-odoo/ untuk menambah wawasan implementasi Odoo ERP.