Commit 3b9fd9ee by aa.gusti

alamat partner dan company

1 parent c727dcc2
......@@ -20,13 +20,17 @@ Menydiakan module untuk followup Wajib Pajak/Retribusi.
'images/journal_entries.jpeg'],
'depends': ['base_setup', 'account'],
'data': [
# 'data/res_district.xml',
'data/res.district.csv',
'data/res.district.sub.csv',
'data/res.district.village.csv',
'views/view_config.xml',
'views/partner.xml',
'views/objek_pajak.xml',
'views/district.xml',
'views/sub_district.xml',
'views/village.xml',
'views/sudut_pandang.xml',
'views/company.xml',
'views/pdl_kab_menus.xml',
'security/account_security.xml',
'security/ir.model.access.csv',
......
"id","state_id","name","code","typ"
ct_jb_19,JB,"Ciamis","19","kab"
ct_jb_71,JB,"Bogor","71","kota"
ct_jb_76,JB,"Depok","76","kota"
ct_jt_19,JT,"Cilacap","19","kab"
"id","district_id:id","name","code"
sub_jb_19_001,ct_jb_19,"Kawali","001"
sub_jt_19_001,ct_jt_19,"Cilacap","001"
"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"
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<record id="st_3276" model="res.district">
<record id="st_jb_76" model="res.district">
<field name="typ">kota</field>
<field name="name">Depok</field>
<field name="code">3276</field>
<field name="state_id" ref="32" />
<field name="state_id" ref="JB" />
</record>
</data>
</odoo>
\ No newline at end of file
......@@ -4,3 +4,4 @@ _logger = logging.getLogger(__name__)
from . import partner
from . import district
from . import pdl_sudut_pandang
from . import company
\ No newline at end of file
import logging
from odoo import models, fields, api
class Company(models.Model):
_name = 'res.company'
_inherit = 'res.company'
test = fields.Char()
district_id = fields.Many2one(
'res.district', compute='_compute_address', inverse='_inverse_district',
string="Kab/Kota", domain="[('state_id', '=?', state_id)]"
)
sub_district_id = fields.Many2one(
'res.district.sub', compute='_compute_address', inverse='_inverse_sub_district',
string="Kab/Kota", domain="[('district_id', '=?', district_id)]"
)
village_id = fields.Many2one(
'res.district.village', compute='_compute_address', inverse='_inverse_village',
string="Desa/Kelurahan", domain="[('sub_district_id', '=?', sub_district_id)]"
)
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_district(self):
for company in self:
company.partner_id.district_id = company.district_id
def _inverse_sub_district(self):
for company in self:
company.partner_id.sub_district_id = company.sub_district_id
def _inverse_village(self):
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:
self.sub_district_id = self.village_id.sub_district_id
@api.onchange('sub_district_id')
def _onchange_sub_district(self):
if self.sub_district_id.district_id:
self.district_id = self.sub_district_id.district_id
@api.onchange('district_id')
def _onchange_district(self):
if self.district_id.state_id:
self.state_id = self.district_id.state_id
......@@ -5,6 +5,8 @@ from odoo.osv import expression
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]
......@@ -93,8 +95,9 @@ 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', self.typ), self.name,
get_selection_label(self, self._name, 'typ', record.typ), record.name,
record.state_id.code, record.code)))
return result
......@@ -136,18 +139,24 @@ class SubDistrict(models.Model):
district_id = fields.Many2one('res.district', string='Kabupaten/Kota', required=True)
code = fields.Char(string="Kode Kecamatan")
name = fields.Char(string="Nama Kecamatan", index=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,
_sql_constraints = [
('code_uniq', 'unique (district_id,code)', 'Kode Kecamatan Harus Unik !'),
('name_uniq', 'unique (district_id,name)', 'Nama Kecamatan Harus Unik !'),
]
def code_get(self):
result = []
for record in self:
result.append((record.id, "{}.{}.{}".format(
record.district_id.state_id.code, record.district_id.code,
record.code)))
return result
def name_get(self):
result = []
for record in self:
result.append((record.id, "{} ({}.{}.{})".format(
self.name, record.district_id.state_id.code,
record.name, record.district_id.state_id.code,
record.district_id.code, record.code)))
return result
......@@ -155,15 +164,14 @@ class SubDistrict(models.Model):
class Village(models.Model):
_name = 'res.district.village'
_description = "Desa/Keurahan"
sub_district_id = fields.Many2one('res.district.sub', string='Kecamatan', required=True)
sub_district_id = fields.Many2one('res.district.sub', string='Kecamatan',
required=True)
typ = fields.Selection([
('desa', 'Desa'),
('kelurahan', 'Kelurahan')],
string='Jenis')
code = fields.Char(string="Kode Desa/Kelurahan")
name = fields.Char(string="Nama Desa/Kelurahan", index=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,
_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 !'),
......@@ -182,7 +190,7 @@ class Village(models.Model):
result = []
for record in self:
result.append((record.id, "{} {} ({}.{}.{}.{})".format(
get_selection_label(self, self._name, 'typ', self.typ), self.name,
get_selection_label(self, self._name, 'typ', record.typ), record.name,
record.sub_district_id.district_id.state_id.code,
record.sub_district_id.district_id.code,
record.sub_district_id.code, record.code)))
......
import time
import logging
from odoo import fields, models, api
from psycopg2 import sql, DatabaseError
from odoo import api, fields, models, _
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT
from odoo.exceptions import ValidationError
from odoo.addons.base.models.res_partner import WARNING_MESSAGE, WARNING_HELP
ADDRESS_FIELDS = ('street', 'street2', 'zip', 'city', 'state_id', 'country_id',
'village_id', 'sub_district_id', 'district_id')
class ResPartner(models.Model):
_name = 'res.partner'
_inherit = 'res.partner'
# is_hotel = fields.Boolean(string='Is a Hotel', default=False,
# help="Check if the contact is a hotel, otherwise it is non hotel")
district_id = fields.Many2one('res.district', string="Kabupaten/Kota")
sub_district_id = fields.Many2one('res.district.sub', string="Kecamatan")
village_id = fields.Many2one('res.district.village', string="Desa/Kelurahan")
@api.model
def _address_fields(self):
"""Returns the list of address fields that are synced from the parent."""
return list(ADDRESS_FIELDS)
@api.onchange('village_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
@api.onchange('sub_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_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 not self.state_id or self.state_id != self.district_id.state_id:
self.district_id = False
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="view_company_form_pdl_kab" model="ir.ui.view">
<field name="name">res.company.form.inherit.pdl.kab</field>
<field name="model">res.company</field>
<field name="inherit_id" ref="account.view_company_form"/>
<field name="priority">4</field>
<field name="arch" type="xml">
<xpath expr="//field[@name='city']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//field[@name='city']" position="after">
<field name="village_id" class="o_address_state" placeholder="Desa/Kel"
options='{"no_open": True}'/>
<field name="sub_district_id" class="o_address_state" placeholder="Kecamatan"
options='{"no_open": True}'/>
<field name="district_id" class="o_address_state" placeholder="Kab/Kota"
options='{"no_open": True}'/>
</xpath>
</field>
</record>
<record id="action_company_config_pdl_kab" model="ir.actions.act_window">
<field name="name">Lembaga/Organisasi</field>
<field name="res_model">res.company</field>
<field name="view_mode">kanban,tree,form</field>
<field name="view_id" ref="base.view_company_tree"/>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Lembaga/Organisasi
</p>
</field>
</record>
</data>
</odoo>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="action_partner_config_pdl_kab" model="ir.actions.act_window">
<field name="name">Partner</field>
<field name="res_model">res.partner</field>
<field name="view_mode">kanban,tree,form</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Partner
</p>
</field>
</record>
<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="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='city']" position="attributes">
<attribute name="invisible">1</attribute>
</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)]}"/>
<field name="sub_district_id" class="o_address_state" placeholder="Kecamatan"
options='{"no_open": True}'
attrs="{'readonly': [('type', '=', 'contact'),('parent_id', '!=', False)]}"/>
<field name="district_id" class="o_address_state" placeholder="Kab/Kota"
options='{"no_open": True}'
attrs="{'readonly': [('type', '=', 'contact'),('parent_id', '!=', False)]}"/>
</xpath>
</field>
</record>
</data>
</odoo>
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="op_hotel_template_tree" model="ir.ui.view">
<field name="name">op.hotel.template.tree</field>
<field name="model">product.template</field>
<field name="arch" type="xml">
<tree string="Objek Pajak Hotel" sample="1">
<field name="default_code" string="NOPD"/>
<field name="name" string="Nama Objek"/>
<field name="lst_price" string="Min Omset"/>
<field name="taxes_id" widget="many2many_tags" string="Pajak"/>
<field name="activity_exception_decoration" widget="activity_exception"/>
</tree>
</field>
</record>
<record id="action_pendataan_hotel_pdl_kab" model="ir.actions.act_window">
<field name="name">Objek Pajak Hotel</field>
<field name="res_model">product.template</field>
<field name="view_mode">kanban,tree,form</field>
<field name="view_id" ref="op_hotel_template_tree"/>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Pendataan Objek Pajak Hotel
</p>
</field>
</record>
<record id="op_hotel_template_form" model="ir.ui.view">
<field name="name">op.hotel.template.form.inherit</field>
<field name="model">product.template</field>
<field name="priority">4</field>
<field name="inherit_id" ref="account.product_template_form_view"/>
<field name="arch" type="xml">
<!-- <xpath expr="//page[@name='general_information']" position="replace"/>-->
<xpath expr="//page[@name='inventory']" position="replace"/>
<xpath expr="//page[@name='sales']" position="replace"/>
<xpath expr="//page[@name='purchase']" position="replace"/>
<!-- <xpath expr="//div[@name='options']" position="after">-->
<!-- Menambah field setelah pricing -->
<!-- <field name="active" invisible=""/>-->
<!-- <field name="categ_id" invisible="0"/>-->
<!-- </xpath>-->
<!-- <xpath expr="//div[@name='default_code']" position="attribute">-->
<!-- <field name="string" string="NOPD"/>-->
<!-- </xpath>-->
</field>
</record>
</data>
</odoo>
\ No newline at end of file
......@@ -49,32 +49,47 @@
parent="config_pdl_kab_menu"
action="action_tax_config_pdl_kab"
sequence="2"/>
<menuitem id="wilayah_config_pdl_kab_menu"
name="Wilayah"
parent="config_pdl_kab_menu"
sequence="2"/>
<menuitem id="state_config_pdl_kab_menu"
name="Provinsi"
parent="config_pdl_kab_menu"
parent="wilayah_config_pdl_kab_menu"
action="action_state_config_pdl_kab"
sequence="2"/>
<menuitem id="district_config_pdl_kab_menu"
name="Kabupaten/Kota"
parent="config_pdl_kab_menu"
parent="wilayah_config_pdl_kab_menu"
action="action_district_config_pdl_kab"
sequence="2"/>
<menuitem id="sub_district_config_pdl_kab_menu"
name="Kecamatan"
parent="config_pdl_kab_menu"
action="action_sub_district_config_pdl_kab"
sequence="2"/>
<menuitem id="village_config_pdl_kab_menu"
name="Desa/Kelurahan"
parent="config_pdl_kab_menu"
action="action_village_config_pdl_kab"
sequence="2"/>
<menuitem id="sub_district_config_pdl_kab_menu"
name="Kecamatan"
parent="wilayah_config_pdl_kab_menu"
action="action_sub_district_config_pdl_kab"
sequence="2"/>
<menuitem id="village_config_pdl_kab_menu"
name="Desa/Kelurahan"
parent="wilayah_config_pdl_kab_menu"
action="action_village_config_pdl_kab"
sequence="2"/>
<menuitem id="sudut_pandang_config_pdl_kab_menu"
name="Sudut Pandang"
parent="config_pdl_kab_menu"
action="action_pdl_sudut_pandang"
sequence="4"/>
<menuitem id="company_config_pdl_kab_menu"
name="Company"
parent="config_pdl_kab_menu"
action="action_company_config_pdl_kab"
sequence="4"/>
<menuitem id="partner_config_pdl_kab_menu"
name="Partner"
parent="config_pdl_kab_menu"
action="action_partner_config_pdl_kab"
sequence="4"/>
</odoo>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!