Commit 6a04cb2a by Owo Sugiana

Kali pertama

0 parents
__pycache__
Catat Warga
===========
Modul Odoo untuk pencatatan warga. Aplikasi untuk Ketua RT.
from . import models
{
'name': 'Warga',
'version': '0.1',
'author': 'opensipkd.com',
'license': 'LGPL-3',
'application': True,
'summary': 'Aplikasi untuk Ketua RT mencatat warganya',
'depends': [
'wilayah',
],
'data': [
'views/res_partner.xml'
]
}
from . import res_partner
from odoo import (
models,
fields,
api,
)
class ResPartner(models.Model):
_inherit = 'res.partner'
kabupaten_id = fields.Many2one(
'kabupaten', string='Kabupaten', ondelete='restrict',
domain="[('state_id', '=?', state_id)]")
kecamatan_id = fields.Many2one(
'kecamatan', string='Kecamatan', ondelete='restrict',
domain="[('kabupaten_id', '=?', kabupaten_id)]")
kelurahan_id = fields.Many2one(
'kelurahan', string='Kelurahan', ondelete='restrict',
domain="[('kecamatan_id', '=?', kecamatan_id)]")
@api.onchange('country_id')
def _onchange_country_id(self):
if self.country_id and self.country_id != self.state_id.country_id:
self.state_id = False
@api.onchange('state_id')
def _onchange_state(self):
if self.state_id:
self.country_id = self.state_id.country_id
if self.state_id != self.kabupaten_id.state_id:
self.kabupaten_id = False
else:
self.kabupaten_id = False
@api.onchange('kabupaten_id')
def _onchange_kabupaten_id(self):
if self.kabupaten_id:
self.state_id = self.kabupaten_id.state_id
self.city = self.kabupaten_id.name
if self.kabupaten_id != self.kecamatan_id.kabupaten_id:
self.kecamatan_id = False
else:
self.kecamatan_id = False
self.city = False
@api.onchange('kecamatan_id')
def _onchange_kecamatan_id(self):
if self.kecamatan_id:
self.kabupaten_id = self.kecamatan_id.kabupaten_id
if self.kecamatan_id != self.kelurahan_id.kecamatan_id:
self.kelurahan_id = False
else:
self.kelurahan_id = False
@api.onchange('kelurahan_id')
def _onchange_kelurahan_id(self):
if self.kelurahan_id:
self.kecamatan_id = self.kelurahan_id.kecamatan_id
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record model="ir.ui.view" id="view_warga_form">
<field name="name">res.warga.form</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="state_id" position="before">
<field name="kelurahan_id" placeholder="Kelurahan"/>
<field name="kecamatan_id" placeholder="Kecamatan"/>
<field name="kabupaten_id" placeholder="Kota / Kabupaten"/>
</field>
</field>
</record>
</data>
</odoo>
from . import models
{
'name': 'Nama Wilayah di Indonesia',
'version': '0.1',
'author': 'opensipkd.com',
'license': 'LGPL-3',
'summary': 'Nama provinsi hingga kelurahan di Indonesia',
'description': 'Sumber: https://github.com/cahyadsn/wilayah',
'depends': [
'base',
],
'data': [
'data/kabupaten.csv',
'data/kecamatan.csv',
'data/kelurahan.csv',
'security/ir.model.access.csv'
]
}
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
from . import wilayah
from odoo import (
models,
fields,
)
class Kabupaten(models.Model):
_name = 'kabupaten'
_description = 'Kota / Kabupaten'
name = fields.Char('Kota / Kabupaten', required=True)
state_id = fields.Many2one(comodel_name='res.country.state', required=True)
_sql_constraints = [
('kabupaten_uniq', 'UNIQUE(state_id, name)',
'Nama kota / kabupaten harus unik')]
class Kecamatan(models.Model):
_name = 'kecamatan'
_description = 'Kecamatan'
name = fields.Char('Kecamatan', required=True)
kabupaten_id = fields.Many2one(comodel_name='kabupaten', required=True)
_sql_constraints = [
('kecamatan_uniq', 'UNIQUE(kabupaten_id, name)',
'Nama kabupaten + kecamatan harus unik')]
class Kelurahan(models.Model):
_name = 'kelurahan'
_description = 'Desa / Kelurahan'
name = fields.Char('Kelurahan', required=True)
kecamatan_id = fields.Many2one(comodel_name='kecamatan', required=True)
_sql_constraints = [
('kelurahan_uniq', 'UNIQUE(kecamatan_id, name)',
'Nama kecamatan + kelurahan harus unik')]
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_kabupaten,access.kabupaten,model_kabupaten,base.group_user,1,0,0,0
access_kecamatan,access.kecamatan,model_kecamatan,base.group_user,1,0,0,0
access_kelurahan,access.kelurahan,model_kelurahan,base.group_user,1,0,0,0
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!