summaryrefslogtreecommitdiff
path: root/indoteknik_api/models/res_users.py
diff options
context:
space:
mode:
authorIT Fixcomart <it@fixcomart.co.id>2023-01-05 04:26:58 +0000
committerIT Fixcomart <it@fixcomart.co.id>2023-01-05 04:26:58 +0000
commitd37c78617706d6313bf8c40277d56028f0f28a07 (patch)
treed46e635d9977350d7414248fc9b5a375fd00f3e0 /indoteknik_api/models/res_users.py
parentf56ff7fb53e25c188663f643f06691d8d71bd34a (diff)
parent9a3a8c37b65d6017bae50d56b4c5bd1ea641a3b1 (diff)
Merged in staging (pull request #14)
Staging
Diffstat (limited to 'indoteknik_api/models/res_users.py')
-rw-r--r--indoteknik_api/models/res_users.py51
1 files changed, 51 insertions, 0 deletions
diff --git a/indoteknik_api/models/res_users.py b/indoteknik_api/models/res_users.py
new file mode 100644
index 00000000..2cab29bd
--- /dev/null
+++ b/indoteknik_api/models/res_users.py
@@ -0,0 +1,51 @@
+from odoo import models
+
+
+class ResUsers(models.Model):
+ _inherit = 'res.users'
+
+ def api_single_response(self, res_user, with_detail=''):
+ data = {
+ 'id': res_user.id,
+ 'name': res_user.name,
+ 'email': res_user.login,
+ 'phone': res_user.phone or '',
+ 'mobile': res_user.mobile or '',
+ 'external': res_user.share
+ }
+
+ return data
+
+ def api_address_response(self, user):
+ data = {
+ 'id': user.id,
+ 'name': user.name,
+ 'mobile': user.mobile,
+ 'street': user.street,
+ 'street2': user.street2,
+ 'city': None,
+ 'district': None,
+ 'sub_district': None,
+ 'zip': user.zip
+ }
+
+ if user.kota_id:
+ data['city'] = {
+ 'id': user.kota_id.id,
+ 'name': user.kota_id.name
+ } or None
+
+ if user.kecamatan_id:
+ data['district'] = {
+ 'id': user.kecamatan_id.id,
+ 'name': user.kecamatan_id.name
+ }
+
+ if user.kelurahan_id:
+ data['sub_district'] = {
+ 'id': user.kelurahan_id.id,
+ 'name': user.kelurahan_id.name
+ }
+
+ return data
+