from odoo import models, fields,api, _
class RestaurantCabang(models.Model):
_name='restaurant.cabang'
_inherit = ['mail.thread', 'mail.activity.mixin'] #untuk membuat bot chatter / chat history yg dilakukan
_rec_name = 'nama_cabang'
_description = 'Cabang'
nama_cabang = fields.Char(string="Nama Cabang",required=True)
alamat_cabang = fields.Char(string="Alamat Cabang")
user_id = fields.Many2one('res.users', string="Kepala Cabang",required=True)
@api.model
def create(self, vals_list):
result = super(RestaurantCabang, self).create(vals_list)
result.default_coa(result.id)
return result
@api.multi
def default_coa(self, id_baru):
print(id_baru)
val = {
'nama_akun_debit':'Kas',
'detail_jenis_akun_debit': 'harta',
'nama_akun_kredit': 'Pendapatan Penjualan',
'detail_jenis_akun_kredit': 'pendapatan',
'id_cabang': id_baru
}
self.env['restaurant.coa'].create(val)#errror here
print(id_baru)
val = {
'nama_akun_debit':'Harga Pokok Penjualan',
'detail_jenis_akun_debit': 'modal',
'nama_akun_kredit': 'Perlengkapan',
'detail_jenis_akun_kredit': 'harta',
'id_cabang': id_baru
}
self.env['restaurant.coa'].create(val)
#here is my ir.module.access.csv
access_restaurant_coa_administrator,access.restaurant.coa_administrator,restaurant.model_restaurant_coa,group_restaurant_administrator,1,1,1,1