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 b815d854
authored
Nov 22, 2021
by
aa.gusti
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
wajib pajak dan objek pajak
1 parent
3b9fd9ee
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
196 additions
and
46 deletions
data/res.district.sub.csv
data/res.district.village.csv
models/company.py
models/district.py
models/partner.py
views/partner.xml
views/pdl_kab_menus.xml
views/village.xml
data/res.district.sub.csv
View file @
b815d85
"id","district_id:id","name","code"
sub_jb_19_001,ct_jb_19,"
Kawali
","001"
sub_j
t_19_001,ct_jt_19,"Cilacap","001
"
sub_jb_19_001,ct_jb_19,"
Ciamis
","001"
sub_j
b_19_002,ct_jb_19,"Kawali","002
"
sub_jb_71_001,ct_jb_71,"Tanah Sereal","001"
\ No newline at end of file
data/res.district.village.csv
View file @
b815d85
"id","sub_district_id:id","name","code","typ"
vil_jb_19_001_001,sub_jb_19_001,"Kawali","001","desa"
vil_jb_19_002_001,sub_jb_19_001,"Kawali Mukti","002","desa"
vil_jt_19_001_001,sub_jt_19_001,"Cilacap","001","kelurahan"
vil_jt_19_001_002,sub_jt_19_001,"Cilacap Timur","002","kelurahan"
vil_jb_19_001_010,sub_jb_19_001,"Ciamis","010","kelurahan"
vil_jb_19_001_020,sub_jb_19_001,Linggasari,"020","kelurahan"
vil_jb_19_001_030,sub_jb_19_001,Benteng,"030","kelurahan"
vil_jb_19_001_040,sub_jb_19_001,Sindangrasa,"040","kelurahan"
vil_jb_19_001_050,sub_jb_19_001,Maleber,"050","kelurahan"
vil_jb_19_001_060,sub_jb_19_001,Kertasari,"060","kelurahan"
vil_jb_19_001_070,sub_jb_19_001,Cigembor,"070","kelurahan"
vil_jb_19_002_010,sub_jb_19_002,"Citeureup","010","desa"
vil_jb_19_002_020,sub_jb_19_002,"Karangpawitan","020","desa"
vil_jb_19_002_030,sub_jb_19_002,"Kawali","030","desa"
vil_jb_19_002_040,sub_jb_19_002,"Kawalimukti","040","desa"
vil_jb_19_002_050,sub_jb_19_002,"Linggapura","050","desa"
vil_jb_19_002_060,sub_jb_19_002,"Margamulya","060","desa"
vil_jb_19_002_070,sub_jb_19_002,"Purwasari","070","desa"
vil_jb_19_002_080,sub_jb_19_002,"Selasari","080","desa"
vil_jb_19_002_090,sub_jb_19_002,"Sindangsari","090","desa"
vil_jb_19_002_100,sub_jb_19_002,"Talagasari","100","desa"
vil_jb_19_002_110,sub_jb_19_002,"Winduraja","110","desa"
vil_jb_71_001_010,sub_jb_71_001,"Cibadak","010","kelurahan"
vil_jb_71_001_020,sub_jb_71_001,"Kayumanis","020","kelurahan"
vil_jb_71_001_030,sub_jb_71_001,"Kebonpedes","030","kelurahan"
vil_jb_71_001_040,sub_jb_71_001,"Kedungbadak","040","kelurahan"
vil_jb_71_001_050,sub_jb_71_001,"Kedungjaya","050","kelurahan"
vil_jb_71_001_060,sub_jb_71_001,"Kedungwaringin","060","kelurahan"
vil_jb_71_001_070,sub_jb_71_001,"Kencana","070","kelurahan"
vil_jb_71_001_080,sub_jb_71_001,"Mekarwangi","080","kelurahan"
vil_jb_71_001_090,sub_jb_71_001,"Sukadamai","090","kelurahan"
vil_jb_71_001_100,sub_jb_71_001,"Sukaresmi","100","kelurahan"
vil_jb_71_001_110,sub_jb_71_001,"Tanahsareal","110","kelurahan"
\ No newline at end of file
models/company.py
View file @
b815d85
...
...
@@ -20,13 +20,20 @@ class Company(models.Model):
'res.district.village'
,
compute
=
'_compute_address'
,
inverse
=
'_inverse_village'
,
string
=
"Desa/Kelurahan"
,
domain
=
"[('sub_district_id', '=?', sub_district_id)]"
)
company_id
=
fields
.
Many2one
(
'res.company'
,
compute
=
'_compute_address'
,
inverse
=
'_inverse_company'
,
string
=
"Company"
)
def
_get_company_address_field_names
(
self
):
""" Return a list of fields coming from the address partner to match
on company address fields. Fields are labeled same on both models. """
return
[
'street'
,
'street2'
,
'city'
,
'zip'
,
'state_id'
,
'country_id'
,
'district_id'
,
'sub_district_id'
,
'village_id'
]
def
_inverse_company
(
self
):
for
company
in
self
:
company
.
partner_id
.
company_id
=
company
.
id
def
_inverse_district
(
self
):
for
company
in
self
:
company
.
partner_id
.
district_id
=
company
.
district_id
...
...
@@ -39,18 +46,41 @@ class Company(models.Model):
for
company
in
self
:
company
.
partner_id
.
village_id
=
company
.
village_id
@api.onchange
(
'village_id'
)
def
_onchange_village
(
self
):
if
self
.
village_id
.
sub_district_id
:
def
_onchange_village
_id
(
self
):
if
self
.
village_id
and
self
.
village_id
.
sub_district_id
!=
self
.
sub_district_id
:
self
.
sub_district_id
=
self
.
village_id
.
sub_district_id
if
self
.
village_id
and
self
.
village_id
.
zip
and
self
.
village_id
.
zip
!=
self
.
zip
:
self
.
zip
=
self
.
village_id
.
zip
@api.onchange
(
'sub_district_id'
)
def
_onchange_sub_district
(
self
):
if
self
.
sub_district_id
.
district_id
:
def
_onchange_sub_district
_id
(
self
):
if
self
.
sub_district_id
and
self
.
sub_district_id
.
district_id
!=
self
.
district_id
:
self
.
district_id
=
self
.
sub_district_id
.
district_id
if
not
self
.
sub_district_id
or
self
.
sub_district_id
!=
self
.
village_id
.
sub_district_id
:
self
.
village_id
=
False
@api.onchange
(
'district_id'
)
def
_onchange_district
(
self
):
if
self
.
district_id
.
state_id
:
def
_onchange_district
_id
(
self
):
if
self
.
district_id
and
self
.
district_id
.
state_id
!=
self
.
state_id
:
self
.
state_id
=
self
.
district_id
.
state_id
if
not
self
.
district_id
or
self
.
district_id
!=
self
.
sub_district_id
.
district_id
:
self
.
sub_district_id
=
False
@api.onchange
(
'state_id'
)
def
_onchange_state_id
(
self
):
if
self
.
state_id
and
self
.
state_id
.
country_id
!=
self
.
country_id
:
self
.
country_id
=
self
.
state_id
.
country_id
if
not
self
.
state_id
or
self
.
state_id
!=
self
.
district_id
.
state_id
:
self
.
district_id
=
False
@api.onchange
(
'country_id'
)
def
_onchange_country_id
(
self
):
if
not
self
.
country_id
or
self
.
country_id
!=
self
.
state_id
.
country_id
:
self
.
state_id
=
False
models/district.py
View file @
b815d85
import
re
from
.
import
_logger
import
logging
from
odoo
import
api
,
fields
,
models
from
odoo.exceptions
import
ValidationError
from
odoo.osv
import
expression
_logger
=
logging
.
getLogger
(
__name__
)
def
get_selection_label
(
self
,
obj
,
field_name
,
field_value
):
_logger
.
info
(
field_name
)
_logger
.
info
(
field_value
)
return
dict
(
self
.
env
[
obj
]
.
fields_get
(
allfields
=
[
field_name
])[
field_name
][
'selection'
])[
field_value
]
...
...
@@ -14,13 +15,6 @@ 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
:
...
...
@@ -32,7 +26,6 @@ class District(models.Model):
_name
=
'res.district'
_description
=
'Kota/Kabupaten'
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
([
(
'kab'
,
'Kabupaten'
),
(
'kabtif'
,
'Kabupaten Administratif'
),
...
...
@@ -64,6 +57,7 @@ class District(models.Model):
@api.model
def
_name_search
(
self
,
name
,
args
=
None
,
operator
=
'ilike'
,
limit
=
100
,
name_get_uid
=
None
):
args
=
args
or
[]
if
self
.
env
.
context
.
get
(
'state_id'
):
args
=
expression
.
AND
([
args
,
[(
'state_id'
,
'='
,
self
.
env
.
context
.
get
(
'state_id'
))]])
...
...
@@ -76,12 +70,15 @@ class District(models.Model):
first_district_ids
=
self
.
_search
(
expression
.
AND
([
first_domain
,
args
]),
limit
=
limit
,
access_rights_uid
=
name_get_uid
)
if
first_domain
else
[]
return
list
(
first_district_ids
)
+
[
state
_id
for
state
_id
in
self
.
_search
(
expression
.
AND
([
domain
,
args
]),
limit
=
limit
,
access_rights_uid
=
name_get_uid
)
if
state
_id
not
in
first_district_ids
first_ids
=
list
(
first_district_ids
)
+
[
district
_id
for
district
_id
in
self
.
_search
(
expression
.
AND
([
domain
,
args
]),
limit
=
limit
,
access_rights_uid
=
name_get_uid
)
if
district
_id
not
in
first_district_ids
]
_logger
.
info
(
self
.
env
.
context
.
get
(
'country_id'
))
_logger
.
info
(
first_ids
)
return
first_ids
# @api.depends('code')
# def _compute_display_code(self):
...
...
@@ -95,7 +92,6 @@ class District(models.Model):
def
name_get
(
self
):
result
=
[]
for
record
in
self
:
# result.append((record.id, "{} {} ({})".format(record.typ, record.name, record.code)))
result
.
append
((
record
.
id
,
"{} {} ({}.{})"
.
format
(
get_selection_label
(
self
,
self
.
_name
,
'typ'
,
record
.
typ
),
record
.
name
,
record
.
state_id
.
code
,
record
.
code
)))
...
...
@@ -144,6 +140,28 @@ class SubDistrict(models.Model):
(
'name_uniq'
,
'unique (district_id,name)'
,
'Nama Kecamatan Harus Unik !'
),
]
@api.model
def
_name_search
(
self
,
name
,
args
=
None
,
operator
=
'ilike'
,
limit
=
100
,
name_get_uid
=
None
):
args
=
args
or
[]
if
self
.
env
.
context
.
get
(
'district_id'
):
args
=
expression
.
AND
([
args
,
[(
'district_id'
,
'='
,
self
.
env
.
context
.
get
(
'district_id'
))]])
if
operator
==
'ilike'
and
not
(
name
or
''
)
.
strip
():
first_domain
=
[]
domain
=
[]
else
:
first_domain
=
[(
'code'
,
'=ilike'
,
name
)]
domain
=
[(
'name'
,
operator
,
name
)]
first_sub_district_ids
=
self
.
_search
(
expression
.
AND
([
first_domain
,
args
]),
limit
=
limit
,
access_rights_uid
=
name_get_uid
)
if
first_domain
else
[]
return
list
(
first_sub_district_ids
)
+
[
district_id
for
district_id
in
self
.
_search
(
expression
.
AND
([
domain
,
args
]),
limit
=
limit
,
access_rights_uid
=
name_get_uid
)
if
district_id
not
in
first_sub_district_ids
]
def
code_get
(
self
):
result
=
[]
for
record
in
self
:
...
...
@@ -172,11 +190,39 @@ class Village(models.Model):
string
=
'Jenis'
)
code
=
fields
.
Char
(
string
=
"Kode Desa/Kelurahan"
)
name
=
fields
.
Char
(
string
=
"Nama Desa/Kelurahan"
,
index
=
True
)
zip
=
fields
.
Char
(
string
=
"Kode Pos Desa/Kelurahan"
,
size
=
5
,
)
_sql_constraints
=
[
(
'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 !'
),
]
@api.model
def
_name_search
(
self
,
name
,
args
=
None
,
operator
=
'ilike'
,
limit
=
100
,
name_get_uid
=
None
):
args
=
args
or
[]
if
self
.
env
.
context
.
get
(
'sub_district_id'
):
args
=
expression
.
AND
([
args
,
[(
'sub_district_id'
,
'='
,
self
.
env
.
context
.
get
(
'sub_district_id'
))]])
_logger
.
info
(
self
.
env
.
context
.
get
(
'sub_district_id'
))
_logger
.
info
(
args
)
if
operator
==
'ilike'
and
not
(
name
or
''
)
.
strip
():
first_domain
=
[]
domain
=
[]
else
:
first_domain
=
[(
'code'
,
'=ilike'
,
name
)]
domain
=
[(
'name'
,
operator
,
name
)]
first_village_ids
=
self
.
_search
(
expression
.
AND
([
first_domain
,
args
]),
limit
=
limit
,
access_rights_uid
=
name_get_uid
)
if
first_domain
else
[]
first_ids
=
list
(
first_village_ids
)
+
[
sub_district_id
for
sub_district_id
in
self
.
_search
(
expression
.
AND
([
domain
,
args
]),
limit
=
limit
,
access_rights_uid
=
name_get_uid
)
if
sub_district_id
not
in
first_village_ids
]
_logger
.
info
(
first_ids
)
_logger
.
info
(
first_village_ids
)
return
first_ids
def
code_get
(
self
):
result
=
[]
for
record
in
self
:
...
...
@@ -195,3 +241,9 @@ class Village(models.Model):
record
.
sub_district_id
.
district_id
.
code
,
record
.
sub_district_id
.
code
,
record
.
code
)))
return
result
@api.constrains
(
'zip'
)
def
_check_zip
(
self
):
if
self
.
zip
:
if
len
(
self
.
zip
)
<
5
:
raise
ValidationError
(
'Kode Pos harus 5 digit'
)
models/partner.py
View file @
b815d85
...
...
@@ -6,11 +6,31 @@ ADDRESS_FIELDS = ('street', 'street2', 'zip', 'city', 'state_id', 'country_id',
class
ResPartner
(
models
.
Model
):
_inherit
=
'res.partner'
district_id
=
fields
.
Many2one
(
'res.district'
,
string
=
"Kabupaten/Kota"
)
company_id
=
fields
.
Many2one
(
'res.company'
,
string
=
"Company"
,
default
=
lambda
self
:
self
.
env
.
company
.
id
if
not
self
.
company_id
else
False
)
country_id
=
fields
.
Many2one
(
'res.country'
,
string
=
"Country"
,
default
=
lambda
self
:
self
.
env
.
company
.
country_id
if
not
self
.
country_id
else
False
)
state_id
=
fields
.
Many2one
(
'res.country.state'
,
string
=
"State"
,
default
=
lambda
self
:
self
.
env
.
company
.
state_id
if
not
self
.
state_id
else
False
)
district_id
=
fields
.
Many2one
(
'res.district'
,
string
=
"Kabupaten/Kota"
,
default
=
lambda
self
:
self
.
env
.
company
.
district_id
if
not
self
.
district_id
else
False
)
sub_district_id
=
fields
.
Many2one
(
'res.district.sub'
,
string
=
"Kecamatan"
)
village_id
=
fields
.
Many2one
(
'res.district.village'
,
string
=
"Desa/Kelurahan"
)
@api.model
def
_get_default_company
(
self
):
return
self
.
env
.
company
.
district_id
@api.model
def
_address_fields
(
self
):
"""Returns the list of address fields that are synced from the parent."""
return
list
(
ADDRESS_FIELDS
)
...
...
@@ -19,6 +39,8 @@ class ResPartner(models.Model):
def
_onchange_village_id
(
self
):
if
self
.
village_id
and
self
.
village_id
.
sub_district_id
!=
self
.
sub_district_id
:
self
.
sub_district_id
=
self
.
village_id
.
sub_district_id
if
self
.
village_id
and
self
.
village_id
.
zip
and
self
.
village_id
.
zip
!=
self
.
zip
:
self
.
zip
=
self
.
village_id
.
zip
@api.onchange
(
'sub_district_id'
)
def
_onchange_sub_district_id
(
self
):
...
...
views/partner.xml
View file @
b815d85
...
...
@@ -2,20 +2,31 @@
<odoo>
<data>
<record
id=
"action_partner_config_pdl_kab"
model=
"ir.actions.act_window"
>
<field
name=
"name"
>
Partner
</field>
<field
name=
"name"
>
Wajib Pajak
</field>
<field
name=
"res_model"
>
res.partner
</field>
<field
name=
"view_mode"
>
kanban,tree,form
</field>
<!-- <field name="view_id" ref="partner_form_pdl_kab"/>-->
<field
name=
"context"
>
{'search_default_customer': 1,
'res_partner_search_mode': 'customer',
'default_is_company': True,
'default_customer_rank': 1,
'country_id': context.get('company.country_id',False)
}
</field>
<field
name=
"help"
type=
"html"
>
<p
class=
"o_view_nocontent_smiling_face"
>
Partner
Wajib Pajak
</p>
</field>
</record>
<!-- options='{"no_open": True, "no_create": True}'-->
<!-- options='{"no_open": True, "no_create": True}'-->
<!-- options='{"no_open": True, "no_create": True}'-->
<record
id=
"partner_form_pdl_kab"
model=
"ir.ui.view"
>
<field
name=
"name"
>
partner.form.pdl.kab.inherit
</field>
<field
name=
"model"
>
res.partner
</field>
<field
name=
"priority"
>
4
</field>
<field
name=
"priority"
>
9
</field>
<field
name=
"inherit_id"
ref=
"base.view_partner_form"
/>
<field
name=
"arch"
type=
"xml"
>
<xpath
expr=
"//field[@name='city']"
position=
"attributes"
>
...
...
@@ -23,14 +34,23 @@
</xpath>
<xpath
expr=
"//field[@name='state_id']"
position=
"before"
>
<field
name=
"village_id"
class=
"o_address_state"
placeholder=
"Desa/Kel"
options=
'{"no_open": True}'
attrs=
"{'readonly': [('type', '=', 'contact'),('parent_id', '!=', False)]}"
/>
options=
"{'no_open': True, 'no_quick_create': True}"
attrs=
"{'readonly': [('type', '=', 'contact'),('parent_id', '!=', False)]}"
context=
"{'sub_district_id':
sub_district_id,
'default_sub_district_id':
sub_district_id,
'district_id':
district_id}"
domain=
"[('sub_district_id', '=?', sub_district_id)]"
/>
<field
name=
"sub_district_id"
class=
"o_address_state"
placeholder=
"Kecamatan"
options=
'{"no_open": True}'
attrs=
"{'readonly': [('type', '=', 'contact'),('parent_id', '!=', False)]}"
/>
options=
"{'no_open': True, 'no_quick_create': True}"
attrs=
"{'readonly': [('type', '=', 'contact'),('parent_id', '!=', False)]}"
context=
"{'district_id':
district_id,
'default_district_id':
district_id,
'state_id':state_id}"
domain=
"[('district_id', '=?', district_id)]"
/>
<field
name=
"district_id"
class=
"o_address_state"
placeholder=
"Kab/Kota"
options=
'{"no_open": True}'
attrs=
"{'readonly': [('type', '=', 'contact'),('parent_id', '!=', False)]}"
/>
options=
"{'no_open': True, 'no_quick_create': True}"
attrs=
"{'readonly': [('type', '=', 'contact'),('parent_id', '!=', False)]}"
context=
"{'state_id': state_id, 'default_state_id': state_id}"
domain=
"[('state_id', '=?', state_id)]"
/>
</xpath>
</field>
</record>
...
...
views/pdl_kab_menus.xml
View file @
b815d85
...
...
@@ -81,12 +81,12 @@
sequence=
"4"
/>
<menuitem
id=
"company_config_pdl_kab_menu"
name=
"
Company
"
name=
"
Pemerintah Daerah/Organisasi
"
parent=
"config_pdl_kab_menu"
action=
"action_company_config_pdl_kab"
sequence=
"4"
/>
<menuitem
id=
"partner_config_pdl_kab_menu"
name=
"
Partner
"
name=
"
Wajib Pajak
"
parent=
"config_pdl_kab_menu"
action=
"action_partner_config_pdl_kab"
sequence=
"4"
/>
...
...
views/village.xml
View file @
b815d85
...
...
@@ -10,6 +10,7 @@
<field
name=
"typ"
string=
"Jenis"
/>
<field
name=
"code"
string=
"Kode"
/>
<field
name=
"sub_district_id"
/>
<field
name=
"zip"
string=
"ZIP"
/>
</tree>
</field>
</record>
...
...
@@ -34,9 +35,10 @@
<form>
<group>
<field
name=
"sub_district_id"
string=
"Kecamatan"
/>
<field
name=
"typ"
string=
"Jenis"
/>
<field
name=
"code"
string=
"Kode"
/>
<field
name=
"typ"
string=
"Jenis"
/>
<field
name=
"name"
string=
"Nama"
/>
<field
name=
"zip"
string=
"Kode Pos"
/>
</group>
</form>
</field>
...
...
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