Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
aa.gusti
/
odoo-dev
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit c727dcc2
authored
Nov 20, 2021
by
aa.gusti
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
perbaikan wilayah
1 parent
32052b99
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
98 additions
and
34 deletions
__manifest__.py
data/res_district.xml
data/state.xml
models/__init__.py
models/district.py
views/district.xml
views/sub_district.xml
views/village.xml
__manifest__.py
View file @
c727dcc
...
@@ -20,6 +20,7 @@ Menydiakan module untuk followup Wajib Pajak/Retribusi.
...
@@ -20,6 +20,7 @@ Menydiakan module untuk followup Wajib Pajak/Retribusi.
'images/journal_entries.jpeg'
],
'images/journal_entries.jpeg'
],
'depends'
:
[
'base_setup'
,
'account'
],
'depends'
:
[
'base_setup'
,
'account'
],
'data'
:
[
'data'
:
[
# 'data/res_district.xml',
'views/view_config.xml'
,
'views/view_config.xml'
,
'views/objek_pajak.xml'
,
'views/objek_pajak.xml'
,
'views/district.xml'
,
'views/district.xml'
,
...
...
data/res_district.xml
0 → 100644
View file @
c727dcc
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data
noupdate=
"1"
>
<record
id=
"st_3276"
model=
"res.district"
>
<field
name=
"typ"
>
kota
</field>
<field
name=
"name"
>
Depok
</field>
<field
name=
"code"
>
3276
</field>
<field
name=
"state_id"
ref=
"32"
/>
</record>
</data>
</odoo>
\ No newline at end of file
\ No newline at end of file
data/state.xml
0 → 100644
View file @
c727dcc
File mode changed
models/__init__.py
View file @
c727dcc
import
logging
_logger
=
logging
.
getLogger
(
__name__
)
from
.
import
partner
from
.
import
partner
from
.
import
district
from
.
import
district
from
.
import
pdl_sudut_pandang
from
.
import
pdl_sudut_pandang
models/district.py
View file @
c727dcc
import
re
import
re
from
.
import
_logger
from
odoo
import
api
,
fields
,
models
from
odoo
import
api
,
fields
,
models
from
odoo.osv
import
expression
from
odoo.osv
import
expression
def
get_selection_label
(
self
,
obj
,
field_name
,
field_value
):
return
dict
(
self
.
env
[
obj
]
.
fields_get
(
allfields
=
[
field_name
])[
field_name
][
'selection'
])[
field_value
]
class
CountryState
(
models
.
Model
):
_inherit
=
'res.country.state'
district_ids
=
fields
.
One2many
(
'res.district'
,
'state_id'
,
string
=
'Kota/Kabupaten'
)
# @api.depends('code')
# def _check_district_code(self):
# _logger.info('Lewat')
# for child in self.district_ids:
# _logger.info(child)
# child.display_code = "{}.{}".format(self.code, child.code)
def
name_get
(
self
):
result
=
[]
for
record
in
self
:
result
.
append
((
record
.
id
,
"{} ({})"
.
format
(
record
.
name
,
record
.
code
)))
return
result
class
District
(
models
.
Model
):
class
District
(
models
.
Model
):
_name
=
'res.district'
_name
=
'res.district'
_description
=
'Kota/Kabupaten'
_description
=
'Kota/Kabupaten'
state_id
=
fields
.
Many2one
(
'res.country.state'
,
string
=
'Provinsi'
,
required
=
True
)
state_id
=
fields
.
Many2one
(
'res.country.state'
,
string
=
'Provinsi'
,
required
=
True
)
# state_code = fields.Many2one('res.country.state', related='state_id.code', store=False)
typ
=
fields
.
Selection
([
typ
=
fields
.
Selection
([
(
'kab'
,
'Kabupaten'
),
(
'kab'
,
'Kabupaten'
),
(
'kabtif'
,
'Kabupaten Administratif'
),
(
'kabtif'
,
'Kabupaten Administratif'
),
(
'kota'
,
'Kota'
),
(
'kota'
,
'Kota'
),
(
'kotif'
,
'Kota Administratif'
)],
(
'kotif'
,
'Kota Administratif'
)],
string
=
'Jenis'
)
string
=
'Jenis'
,
required
=
True
)
code
=
fields
.
Char
(
string
=
"Kode Kota/Kabupaten"
)
code
=
fields
.
Char
(
string
=
"Kode Kota/Kabupaten"
,
required
=
True
)
name
=
fields
.
Char
(
string
=
"Nama Kota/Kabupaten"
,
index
=
True
)
name
=
fields
.
Char
(
string
=
"Nama Kota/Kabupaten"
,
index
=
True
,
required
=
True
)
display_code
=
fields
.
Char
(
index
=
True
)
# display_code = fields.Char(compute='_compute_display_code', store=True, index=True)
# display_code = fields.Char(compute='_compute_display_code') #, store=True, index=True)
# display_name = fields.Char(compute='_compute_display_name', store=True, index=True)
display_name
=
fields
.
Char
(
index
=
True
)
# display_name = fields.Char(compute='_compute_display_name') #, store=True, index=True)
sub_district_ids
=
fields
.
One2many
(
'res.district.sub'
,
'district_id'
,
string
=
'Kecamatan'
)
sub_district_ids
=
fields
.
One2many
(
'res.district.sub'
,
'district_id'
,
string
=
'Kecamatan'
)
# address_view_id = fields.Many2one(
# address_view_id = fields.Many2one(
# comodel_name='ir.ui.view', string="Input View",
# comodel_name='ir.ui.view', string="Input View",
...
@@ -60,10 +81,21 @@ class District(models.Model):
...
@@ -60,10 +81,21 @@ class District(models.Model):
if
state_id
not
in
first_district_ids
if
state_id
not
in
first_district_ids
]
]
# @api.depends('code')
# def _compute_display_code(self):
# self.display_code = "{}.{}".format(self.state_id.code, self.code)
# @api.depends('name')
# def _compute_display_name(self):
# pass
# self.display_name = "{} {}".format(self.typ, self.name)
def
name_get
(
self
):
def
name_get
(
self
):
result
=
[]
result
=
[]
for
record
in
self
:
for
record
in
self
:
result
.
append
((
record
.
id
,
"{} {} ({})"
.
format
(
record
.
typ
,
record
.
name
,
record
.
state_id
.
code
)))
result
.
append
((
record
.
id
,
"{} {} ({}.{})"
.
format
(
get_selection_label
(
self
,
self
.
_name
,
'typ'
,
self
.
typ
),
self
.
name
,
record
.
state_id
.
code
,
record
.
code
)))
return
result
return
result
def
code_get
(
self
):
def
code_get
(
self
):
...
@@ -72,16 +104,6 @@ class District(models.Model):
...
@@ -72,16 +104,6 @@ class District(models.Model):
result
.
append
((
record
.
id
,
"{}.{}"
.
format
(
record
.
state_id
.
code
,
record
.
code
)))
result
.
append
((
record
.
id
,
"{}.{}"
.
format
(
record
.
state_id
.
code
,
record
.
code
)))
return
result
return
result
@api.depends
(
'name'
)
def
_compute_display_name
(
self
):
pass
# self.display_name = "{} {}".format(self.typ, self.name)
@api.depends
(
'code'
)
def
_compute_display_code
(
self
):
pass
# self.display_code = "{}.{}".format(self.state_id.code, self.code)
# @api.model_create_multi
# @api.model_create_multi
# def create(self, vals_list):
# def create(self, vals_list):
# for vals in vals_list:
# for vals in vals_list:
...
@@ -114,13 +136,21 @@ class SubDistrict(models.Model):
...
@@ -114,13 +136,21 @@ class SubDistrict(models.Model):
district_id
=
fields
.
Many2one
(
'res.district'
,
string
=
'Kabupaten/Kota'
,
required
=
True
)
district_id
=
fields
.
Many2one
(
'res.district'
,
string
=
'Kabupaten/Kota'
,
required
=
True
)
code
=
fields
.
Char
(
string
=
"Kode Kecamatan"
)
code
=
fields
.
Char
(
string
=
"Kode Kecamatan"
)
name
=
fields
.
Char
(
string
=
"Nama Kecamatan"
,
index
=
True
)
name
=
fields
.
Char
(
string
=
"Nama Kecamatan"
,
index
=
True
)
display_code
=
fields
.
Char
(
index
=
True
)
# compute='_compute_display_code', store=True,
#
display_code = fields.Char(index=True) # compute='_compute_display_code', store=True,
# display_name = fields.Char(index=True) # compute='_compute_display_name', store=True,
# display_name = fields.Char(index=True) # compute='_compute_display_name', store=True,
_sql_constraints
=
[
_sql_constraints
=
[
(
'code_uniq'
,
'unique (district_id,code)'
,
'Kode Kecamatan Harus Unik !'
),
(
'code_uniq'
,
'unique (district_id,code)'
,
'Kode Kecamatan Harus Unik !'
),
(
'name_uniq'
,
'unique (district_id,name)'
,
'Nama Kecamatan Harus Unik !'
),
(
'name_uniq'
,
'unique (district_id,name)'
,
'Nama Kecamatan Harus Unik !'
),
]
]
def
name_get
(
self
):
result
=
[]
for
record
in
self
:
result
.
append
((
record
.
id
,
"{} ({}.{}.{})"
.
format
(
self
.
name
,
record
.
district_id
.
state_id
.
code
,
record
.
district_id
.
code
,
record
.
code
)))
return
result
class
Village
(
models
.
Model
):
class
Village
(
models
.
Model
):
_name
=
'res.district.village'
_name
=
'res.district.village'
...
@@ -132,9 +162,28 @@ class Village(models.Model):
...
@@ -132,9 +162,28 @@ class Village(models.Model):
string
=
'Jenis'
)
string
=
'Jenis'
)
code
=
fields
.
Char
(
string
=
"Kode Desa/Kelurahan"
)
code
=
fields
.
Char
(
string
=
"Kode Desa/Kelurahan"
)
name
=
fields
.
Char
(
string
=
"Nama Desa/Kelurahan"
,
index
=
True
)
name
=
fields
.
Char
(
string
=
"Nama Desa/Kelurahan"
,
index
=
True
)
display_code
=
fields
.
Char
(
index
=
True
)
# compute='_compute_display_code', store=True,
#
display_code = fields.Char(index=True) # compute='_compute_display_code', store=True,
display_name
=
fields
.
Char
(
index
=
True
)
# compute='_compute_display_name', store=True,
#
display_name = fields.Char(index=True) # compute='_compute_display_name', store=True,
_sql_constraints
=
[
_sql_constraints
=
[
(
'village_code_uniq'
,
'unique (sub_district_id,code)'
,
'Kode Kelurahan/Desa Harus Unik !'
),
(
'village_code_uniq'
,
'unique (sub_district_id,code)'
,
'Kode Kelurahan/Desa Harus Unik !'
),
(
'village_name_uniq'
,
'unique (sub_district_id,typ,name)'
,
'Nama Kelurahan/Desa Harus Unik !'
),
(
'village_name_uniq'
,
'unique (sub_district_id,typ,name)'
,
'Nama Kelurahan/Desa Harus Unik !'
),
]
]
def
code_get
(
self
):
result
=
[]
for
record
in
self
:
result
.
append
((
record
.
id
,
"{}.{}.{}"
.
format
(
record
.
sub_district_id
.
district_id
.
state_id
.
code
,
record
.
sub_district_id
.
district_id
.
code
,
record
.
sub_district_id
.
code
,
record
.
code
)))
return
result
def
name_get
(
self
):
result
=
[]
for
record
in
self
:
result
.
append
((
record
.
id
,
"{} {} ({}.{}.{}.{})"
.
format
(
get_selection_label
(
self
,
self
.
_name
,
'typ'
,
self
.
typ
),
self
.
name
,
record
.
sub_district_id
.
district_id
.
state_id
.
code
,
record
.
sub_district_id
.
district_id
.
code
,
record
.
sub_district_id
.
code
,
record
.
code
)))
return
result
views/district.xml
View file @
c727dcc
...
@@ -17,10 +17,10 @@
...
@@ -17,10 +17,10 @@
<field
name=
"model"
>
res.district
</field>
<field
name=
"model"
>
res.district
</field>
<field
name=
"arch"
type=
"xml"
>
<field
name=
"arch"
type=
"xml"
>
<tree
string=
"Kabupaten/Kota"
sample=
"1"
>
<tree
string=
"Kabupaten/Kota"
sample=
"1"
>
<field
name=
"
display_code"
string=
"Prov
"
/>
<field
name=
"
name"
string=
"Nama
"
/>
<field
name=
"typ"
string=
"Jenis"
/>
<field
name=
"typ"
string=
"Jenis"
/>
<field
name=
"code"
string=
"Kode"
/>
<field
name=
"code"
string=
"Kode"
/>
<field
name=
"
name"
string=
"Nama
"
/>
<field
name=
"
state_id"
options=
"{'no_create': True}
"
/>
</tree>
</tree>
</field>
</field>
</record>
</record>
...
@@ -46,8 +46,7 @@
...
@@ -46,8 +46,7 @@
<group>
<group>
<field
name=
"state_id"
string=
"Provinsi"
/>
<field
name=
"state_id"
string=
"Provinsi"
/>
<field
name=
"typ"
string=
"Jenis"
/>
<field
name=
"typ"
string=
"Jenis"
/>
<field
name=
"code"
string=
"Kabupaten/Kota"
/>
<field
name=
"code"
string=
"Kode"
/>
<field
name=
"display_code"
string=
"Full Kode"
/>
<field
name=
"name"
string=
"Nama"
/>
<field
name=
"name"
string=
"Nama"
/>
</group>
</group>
</form>
</form>
...
...
views/sub_district.xml
View file @
c727dcc
...
@@ -6,9 +6,10 @@
...
@@ -6,9 +6,10 @@
<field
name=
"model"
>
res.district.sub
</field>
<field
name=
"model"
>
res.district.sub
</field>
<field
name=
"arch"
type=
"xml"
>
<field
name=
"arch"
type=
"xml"
>
<tree
string=
"Kecamatan"
sample=
"1"
>
<tree
string=
"Kecamatan"
sample=
"1"
>
<field
name=
"display_code"
string=
"Kode"
/>
<field
name=
"code"
string=
"Kode"
/>
<field
name=
"name"
string=
"Nama"
/>
<field
name=
"name"
string=
"Nama"
/>
<field
name=
"code"
string=
"Kode"
/>
<field
name=
"district_id"
/>
</tree>
</tree>
</field>
</field>
</record>
</record>
...
@@ -33,8 +34,8 @@
...
@@ -33,8 +34,8 @@
<form>
<form>
<group>
<group>
<field
name=
"district_id"
string=
"Kabupaten/Kota"
/>
<field
name=
"district_id"
string=
"Kabupaten/Kota"
/>
<field
name=
"code"
string=
"K
ecamatan
"
/>
<field
name=
"code"
string=
"K
ode
"
/>
<field
name=
"display_code"
string=
"Full Kode"
/
>
<!-- <field name="display_code" string="Full Kode"/>--
>
<field
name=
"name"
string=
"Nama"
/>
<field
name=
"name"
string=
"Nama"
/>
</group>
</group>
</form>
</form>
...
...
views/village.xml
View file @
c727dcc
...
@@ -6,9 +6,10 @@
...
@@ -6,9 +6,10 @@
<field
name=
"model"
>
res.district.village
</field>
<field
name=
"model"
>
res.district.village
</field>
<field
name=
"arch"
type=
"xml"
>
<field
name=
"arch"
type=
"xml"
>
<tree
string=
"Desa/Kelurahan"
sample=
"1"
>
<tree
string=
"Desa/Kelurahan"
sample=
"1"
>
<field
name=
"display_code"
string=
"Kode"
/>
<field
name=
"code"
string=
"Kode"
/>
<field
name=
"name"
string=
"Nama"
/>
<field
name=
"name"
string=
"Nama"
/>
<field
name=
"typ"
string=
"Jenis"
/>
<field
name=
"code"
string=
"Kode"
/>
<field
name=
"sub_district_id"
/>
</tree>
</tree>
</field>
</field>
</record>
</record>
...
@@ -32,10 +33,9 @@
...
@@ -32,10 +33,9 @@
<field
name=
"arch"
type=
"xml"
>
<field
name=
"arch"
type=
"xml"
>
<form>
<form>
<group>
<group>
<field
name=
"display_code"
string=
"Full Kode"
/>
<field
name=
"sub_district_id"
string=
"Kecamatan"
/>
<field
name=
"sub_district_id"
string=
"Kecamatan"
/>
<field
name=
"typ"
string=
"Jenis"
/>
<field
name=
"typ"
string=
"Jenis"
/>
<field
name=
"code"
string=
"
Desa/Kelurahan
"
/>
<field
name=
"code"
string=
"
Kode
"
/>
<field
name=
"name"
string=
"Nama"
/>
<field
name=
"name"
string=
"Nama"
/>
</group>
</group>
</form>
</form>
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment