diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-10-01 10:19:47 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-10-01 10:19:47 +0700 |
| commit | 48322cab6c0b10bf85dec9beffffd2c1064aa8a5 (patch) | |
| tree | e31867536ac96460f4961b667603881c7a4dcb6b /indoteknik_api/controllers/api_v1/user.py | |
| parent | f8ba3deeab30a5eee7ccfcbe9cf8a7e664d0bde7 (diff) | |
<iman> update switch account
Diffstat (limited to 'indoteknik_api/controllers/api_v1/user.py')
| -rw-r--r-- | indoteknik_api/controllers/api_v1/user.py | 58 |
1 files changed, 46 insertions, 12 deletions
diff --git a/indoteknik_api/controllers/api_v1/user.py b/indoteknik_api/controllers/api_v1/user.py index b66e0f3c..77dc60d0 100644 --- a/indoteknik_api/controllers/api_v1/user.py +++ b/indoteknik_api/controllers/api_v1/user.py @@ -451,16 +451,48 @@ class User(controller.Controller): match_ratio = SequenceMatcher(None, match_company.name, business_name).ratio() if match_ratio > 0.8: if user.parent_id : - match_company.email = email_partner, - match_company.customer_type = 'pkp' if is_pkp == 'true' else 'nonpkp', - match_company.name = business_name if business_name else business_name, - match_company.company_type_id.id = company_type_id if company_type_id else False, - match_company.industry_id.id = industry_id, - match_company.npwp = npwp if is_pkp == 'true' else (npwp if npwp else '00.000.000.0-000.000'), - match_company.sppkp = sppkp if is_pkp == 'true' else (sppkp if sppkp else '-'), - match_company.nama_wajib_pajak = nama_wajib_pajak, - match_company.alamat_lengkap_text = alamat_wajib_pajak, - match_company.street = alamat_bisnis, + new_data = { + 'email': email_partner, + 'customer_type': 'pkp' if is_pkp == 'true' else 'nonpkp', + 'name': business_name if business_name else business_name, + 'company_type_id': company_type_id if company_type_id else False, + 'industry_id': industry_id, + 'npwp': npwp if is_pkp == 'true' else (npwp if npwp else '00.000.000.0-000.000'), + 'sppkp': sppkp if is_pkp == 'true' else (sppkp if sppkp else '-'), + 'nama_wajib_pajak': nama_wajib_pajak, + 'alamat_lengkap_text': alamat_wajib_pajak, + 'street': alamat_bisnis, + 'active': False, + } + match_company.write(new_data) + + if npwp_document != ' ': + npwp_mimetype, _ = mimetypes.guess_type(npwp_filename) + npwp_mimetype = npwp_mimetype or 'application/octet-stream' + pdf_data = base64.b64decode(npwp_document) + npwp_attachment = request.env['ir.attachment'].create({ + 'name': 'NPWP Document', + 'type': 'binary', + 'datas': base64.b64encode(pdf_data), + 'res_model': 'res.partner', + 'res_id': match_company.id, + 'mimetype': npwp_mimetype + }) + match_company.message_post(body="NPWP Uploaded", attachment_ids=[npwp_attachment.id]) + + if sppkp_document != ' ': + sppkp_mimetype, _ = mimetypes.guess_type(sppkp_filename) + sppkp_mimetype = sppkp_mimetype or 'application/octet-stream' + pdf_data = base64.b64decode(sppkp_document) + sppkp_attachment = request.env['ir.attachment'].create({ + 'name': 'SPPKP Document', + 'type': 'binary', + 'datas': base64.b64encode(pdf_data), + 'res_model': 'res.partner', + 'res_id': match_company.id, + 'mimetype': sppkp_mimetype + }) + match_company.message_post(body="SPPKP Uploaded", attachment_ids=[sppkp_attachment.id]) else: # Create a user company request request.env['user.company.request'].create({ @@ -607,7 +639,8 @@ class User(controller.Controller): ] ) - @http.route(prefix + 'user/chek/npwp/<id>', auth='public', methods=['GET']) + @http.route(prefix + 'user/chek/npwp/<id>', auth='public', methods=['GET', 'OPTIONS']) + @controller.Controller.must_authorized() def chek_npwp(self, **kw): id = int(kw.get('id')) """Download NPWP file for the given company""" @@ -661,7 +694,8 @@ class User(controller.Controller): ] ) - @http.route(prefix + 'user/chek/sppkp/<id>', auth='public', methods=['GET']) + @http.route(prefix + 'user/chek/sppkp/<id>', auth='public', methods=['GET', 'OPTIONS']) + @controller.Controller.must_authorized() def chek_sppkp(self, **kw): id = int(kw.get('id')) """Download SPPKP file for the given company""" |
