diff options
Diffstat (limited to 'indoteknik_api/models')
| -rw-r--r-- | indoteknik_api/models/__init__.py | 1 | ||||
| -rw-r--r-- | indoteknik_api/models/product_product.py | 2 | ||||
| -rw-r--r-- | indoteknik_api/models/res_users.py | 51 |
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 + |
