Commit 41f2de79 by Owo Sugiana

Tambah tanggal lahir

1 parent 5ecef459
from dateutil.relativedelta import relativedelta
from odoo import (
models,
fields,
......@@ -45,6 +46,23 @@ class Partner(models.Model):
rw = fields.Char(string='RW')
rt = fields.Char(string='RT')
hubungan_keluarga = fields.Char() # Kepala Keluarga / Istri / Anak
# https://github.com/OCA/partner-contact/tree/15.0/partner_contact_gender
gender = fields.Selection(
[('male', 'Laki-laki'), ('female', 'Perempuan')])
# https://github.com/OCA/partner-contact/blob/15.0/partner_contact_birthdate
birthdate_date = fields.Date('Tanggal Lahir')
age = fields.Integer(readonly=True, compute='_compute_age')
# https://github.com/OCA/partner-contact/blob/15.0/partner_contact_nationality
nationality_id = fields.Many2one('res.country', 'Warga Negara')
@api.depends("birthdate_date")
def _compute_age(self):
for record in self:
age = 0
if record.birthdate_date:
age = relativedelta(fields.Date.today(), record.birthdate_date)
age = age.years
record.age = age
@api.onchange('l10n_id_nik')
def _onchange_nik(self):
......
......@@ -60,6 +60,7 @@
'default_zip': zip}">
<tree>
<field name="name"/>
<field name="age"/>
<field name="street" string="Jalan / No."/>
<field name="mobile"/>
</tree>
......@@ -72,14 +73,18 @@
<group>
<group>
<field name="name"/>
<field name="street" string="Jalan / No."/>
<field name="gender"/>
<field name="birthdate_date" placeholder="17-8-1945"/>
<field name="age" attrs="{'invisible': [('birthdate_date', '=', False)]}"/>
<field name="mobile" widget="phone"/>
<field name="email" widget="email"/>
<field name="phone" widget="phone"/>
<field name="nationality_id"/>
</group>
<group>
<label for="rt" string="Alamat"/>
<label for="street" string="Alamat"/>
<div class="o_address_format">
<field name="street" string="Jalan / No."/>
<label for="rt" string="RT"/>
<field name="rt"/>
<label for="rw" string="RW"/>
......@@ -108,6 +113,8 @@
'default_zip': zip}">
<tree>
<field name="name"/>
<field name="gender"/>
<field name="age"/>
<field name="hubungan_keluarga"/>
<field name="mobile"/>
</tree>
......@@ -119,10 +126,14 @@
<group>
<group>
<field name="name"/>
<field name="hubungan_keluarga" placeholder="Istri / Anak"/>
<field name="gender"/>
<field name="birthdate_date" placeholder="17-8-1945"/>
<field name="age" attrs="{'invisible': [('birthdate_date', '=', False)]}"/>
<field name="hubungan_keluarga" placeholder="Istri / Anak / Ibu / Bapak"/>
<field name="mobile" widget="phone"/>
<field name="email" widget="email"/>
<field name="phone" widget="phone"/>
<field name="nationality_id"/>
</group>
<group>
<label for="rt" string="Alamat"/>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!