summaryrefslogtreecommitdiff
path: root/indoteknik_api/models
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
parentf56ff7fb53e25c188663f643f06691d8d71bd34a (diff)
parent9a3a8c37b65d6017bae50d56b4c5bd1ea641a3b1 (diff)
Merged in staging (pull request #14)
Staging
Diffstat (limited to 'indoteknik_api/models')
-rw-r--r--indoteknik_api/models/__init__.py1
-rw-r--r--indoteknik_api/models/product_product.py2
-rw-r--r--indoteknik_api/models/res_users.py51
3 files changed, 53 insertions, 1 deletions
diff --git a/indoteknik_api/models/__init__.py b/indoteknik_api/models/__init__.py
index 25f6997f..3e00e2f0 100644
--- a/indoteknik_api/models/__init__.py
+++ b/indoteknik_api/models/__init__.py
@@ -2,4 +2,5 @@ from . import blog_post
from . import product_pricelist
from . import product_product
from . import product_template
+from . import res_users
from . import x_manufactures \ No newline at end of file
diff --git a/indoteknik_api/models/product_product.py b/indoteknik_api/models/product_product.py
index b5253591..6b02d91e 100644
--- a/indoteknik_api/models/product_product.py
+++ b/indoteknik_api/models/product_product.py
@@ -1,7 +1,7 @@
from odoo import models
-class ProductTemplate(models.Model):
+class ProductProduct(models.Model):
_inherit = 'product.product'
def api_single_response(self, product_product):
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
+