From 60abd5d10aa4f606cade5ecf7d5c271905d4a18a Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 26 Aug 2024 14:51:43 +0700 Subject: add new register to try --- indoteknik_api/controllers/api_v1/user.py | 80 ++++++++++++++++++++++++++----- 1 file changed, 67 insertions(+), 13 deletions(-) diff --git a/indoteknik_api/controllers/api_v1/user.py b/indoteknik_api/controllers/api_v1/user.py index b9fd9f56..cc97d004 100644 --- a/indoteknik_api/controllers/api_v1/user.py +++ b/indoteknik_api/controllers/api_v1/user.py @@ -104,12 +104,24 @@ class User(controller.Controller): name = kw.get('name') email = kw.get('email') password = kw.get('password') - if not name or not email or not password: - return self.response(code=400, description='email, name and password is required') - - company = kw.get('company', False) phone = kw.get('phone') + # Form Data + npwp = kw.get('npwp') # File upload for NPWP + npwp_document = kw.get('npwp_document', False) # String input for NPWP document + sppkp = kw.get('sppkp', False) # File upload for SPPKP + sppkp_document = kw.get('sppkp_document', False) # String input for SPPKP document + email_partner = kw.get('email_partner') + business_name = kw.get('business_name', False) + industry_id = int(kw.get('industry_id', '0') or 0) + company_type_id = int(kw.get('company_type_id', '0') or 0) + nama_wajib_pajak = kw.get('nama_wajib_pajak', False) + is_pkp = kw.get('is_pkp') + type_acc = kw.get('type_acc', False) + + if not name or not email or not password: + return self.response(code=400, description='email, name, and password are required') + response = { 'register': False, 'reason': None @@ -125,38 +137,80 @@ class User(controller.Controller): return self.response(response) + # Create user data user_data = { 'name': name, 'login': email, 'phone': phone, 'password': password, - 'active': False, + 'active': True, 'sel_groups_1_9_10': 9 } user = request.env['res.users'].create(user_data) user.partner_id.email = email + user.partner_id.phone = phone - if company: + if type_acc == 'business': parameter = [ ('company_type', '=', 'company'), - ('name', 'ilike', company) + ('name', 'ilike', business_name) ] match_company = request.env['res.partner'].search(parameter, limit=1) match_ratio = 0 if match_company: - match_ratio = SequenceMatcher(None, match_company.name, company).ratio() + match_ratio = SequenceMatcher(None, match_company.name, business_name).ratio() if match_ratio > 0.8: + # Set the user's partner's parent to the matched company + user.partner_id.parent_id = match_company.id + + # Create a user company request request.env['user.company.request'].create({ 'user_id': user.partner_id.id, 'user_company_id': match_company.id, - 'user_input': company + 'user_input': business_name }) else: - new_company = request.env['res.partner'].create({ - 'name': company - }) - user.parent_id = new_company.id + if not nama_wajib_pajak and not is_pkp: + nama_wajib_pajak = business_name + + new_company_data = { + '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, + 'customer_type': 'pkp' if is_pkp else 'nonpkp', + 'npwp': npwp if is_pkp else (npwp if npwp else '0000'), + 'sppkp': sppkp if is_pkp else (sppkp if sppkp else '0000'), + 'nama_wajib_pajak': nama_wajib_pajak, + 'email': email_partner, + 'company_type': 'company' + } + new_company = request.env['res.partner'].create(new_company_data) + user.partner_id.parent_id = new_company.id + + if npwp_document: + pdf_data = base64.b64decode(npwp_document) + npwp_attachment = request.env['ir.attachment'].create({ + 'name': 'NPWP Document', + 'type': 'binary', + 'datas': pdf_data, + 'res_model': 'res.partner', + 'res_id': new_company.id, + 'mimetype': 'application/pdf' + }) + new_company.message_post(body="NPWP Uploaded", attachment_ids=[npwp_attachment.id]) + + if sppkp_document: + pdf_data = base64.b64decode(sppkp_document) + sppkp_attachment = request.env['ir.attachment'].create({ + 'name': 'SPPKP Document', + 'type': 'binary', + 'datas': pdf_data, + 'res_model': 'res.partner', + 'res_id': new_company.id, + 'mimetype': 'application/pdf' + }) + new_company.message_post(body="SPPKP Uploaded", attachment_ids=[sppkp_attachment.id]) user.send_activation_mail() -- cgit v1.2.3 From f8367ac86e743ed7c7119c9ebcadba110c115e36 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 26 Aug 2024 16:07:37 +0700 Subject: update make new company pkp --- indoteknik_api/controllers/api_v1/user.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/indoteknik_api/controllers/api_v1/user.py b/indoteknik_api/controllers/api_v1/user.py index cc97d004..bacf7009 100644 --- a/indoteknik_api/controllers/api_v1/user.py +++ b/indoteknik_api/controllers/api_v1/user.py @@ -178,9 +178,9 @@ class User(controller.Controller): '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, - 'customer_type': 'pkp' if is_pkp else 'nonpkp', - 'npwp': npwp if is_pkp else (npwp if npwp else '0000'), - 'sppkp': sppkp if is_pkp else (sppkp if sppkp else '0000'), + 'customer_type': 'pkp' if is_pkp == 'true' else 'nonpkp', + 'npwp': npwp if is_pkp == 'true' else (npwp if npwp else '0000'), + 'sppkp': sppkp if is_pkp == 'true' else (sppkp if sppkp else '0000'), 'nama_wajib_pajak': nama_wajib_pajak, 'email': email_partner, 'company_type': 'company' -- cgit v1.2.3 From bee9842dda7aff8925f71f520765b0cf017e4526 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 27 Aug 2024 09:53:05 +0700 Subject: cr new register --- indoteknik_api/controllers/api_v1/user.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/indoteknik_api/controllers/api_v1/user.py b/indoteknik_api/controllers/api_v1/user.py index cc97d004..2e2a2cc6 100644 --- a/indoteknik_api/controllers/api_v1/user.py +++ b/indoteknik_api/controllers/api_v1/user.py @@ -107,10 +107,10 @@ class User(controller.Controller): phone = kw.get('phone') # Form Data - npwp = kw.get('npwp') # File upload for NPWP - npwp_document = kw.get('npwp_document', False) # String input for NPWP document - sppkp = kw.get('sppkp', False) # File upload for SPPKP - sppkp_document = kw.get('sppkp_document', False) # String input for SPPKP document + npwp = kw.get('npwp') + npwp_document = kw.get('npwp_document', False) + sppkp = kw.get('sppkp', False) + sppkp_document = kw.get('sppkp_document', False) email_partner = kw.get('email_partner') business_name = kw.get('business_name', False) industry_id = int(kw.get('industry_id', '0') or 0) @@ -179,8 +179,8 @@ class User(controller.Controller): 'company_type_id': company_type_id if company_type_id else False, 'industry_id': industry_id, 'customer_type': 'pkp' if is_pkp else 'nonpkp', - 'npwp': npwp if is_pkp else (npwp if npwp else '0000'), - 'sppkp': sppkp if is_pkp else (sppkp if sppkp else '0000'), + 'npwp': npwp if is_pkp else (npwp if npwp else '0.000.000.0-000.000'), + 'sppkp': sppkp if is_pkp else (sppkp if sppkp else ''), 'nama_wajib_pajak': nama_wajib_pajak, 'email': email_partner, 'company_type': 'company' -- cgit v1.2.3 From cda852c61878d46c14c7c04e8eaaf68a268f6149 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 27 Aug 2024 10:31:32 +0700 Subject: cr api new register --- indoteknik_api/controllers/api_v1/user.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/indoteknik_api/controllers/api_v1/user.py b/indoteknik_api/controllers/api_v1/user.py index 2e2a2cc6..a7e200cd 100644 --- a/indoteknik_api/controllers/api_v1/user.py +++ b/indoteknik_api/controllers/api_v1/user.py @@ -187,6 +187,10 @@ class User(controller.Controller): } new_company = request.env['res.partner'].create(new_company_data) user.partner_id.parent_id = new_company.id + user.partner_id.customer_type = new_company.customer_type + user.partner_id.npwp = new_company.npwp + user.partner_id.sppkp = new_company.sppkp + user.partner_id.nama_wajib_pajak = new_company.nama_wajib_pajak if npwp_document: pdf_data = base64.b64decode(npwp_document) -- cgit v1.2.3 From f7ba6f97d3367e54e3c24eaf24002ca7abbd5383 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 27 Aug 2024 14:48:37 +0700 Subject: update make attachment --- indoteknik_api/controllers/api_v1/user.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/indoteknik_api/controllers/api_v1/user.py b/indoteknik_api/controllers/api_v1/user.py index a7e200cd..59684b4c 100644 --- a/indoteknik_api/controllers/api_v1/user.py +++ b/indoteknik_api/controllers/api_v1/user.py @@ -9,6 +9,8 @@ import string import requests import json from difflib import SequenceMatcher +import mimetypes +import base64 class User(controller.Controller): @@ -106,15 +108,20 @@ class User(controller.Controller): password = kw.get('password') phone = kw.get('phone') + # Form Data # Form Data npwp = kw.get('npwp') npwp_document = kw.get('npwp_document', False) + npwp_filename = kw.get('npwp_filename', 'npwp_document') sppkp = kw.get('sppkp', False) sppkp_document = kw.get('sppkp_document', False) + sppkp_filename = kw.get('sppkp_filename', 'sppkp_document') email_partner = kw.get('email_partner') business_name = kw.get('business_name', False) industry_id = int(kw.get('industry_id', '0') or 0) company_type_id = int(kw.get('company_type_id', '0') or 0) + alamat_wajib_pajak = kw.get('alamat_wajib_pajak', False) + alamat_bisnis = kw.get('alamat_bisnis', False) nama_wajib_pajak = kw.get('nama_wajib_pajak', False) is_pkp = kw.get('is_pkp') type_acc = kw.get('type_acc', False) @@ -174,6 +181,9 @@ class User(controller.Controller): if not nama_wajib_pajak and not is_pkp: nama_wajib_pajak = business_name + if not alamat_wajib_pajak and not is_pkp: + alamat_wajib_pajak = alamat_bisnis + new_company_data = { 'name': business_name if business_name else business_name, 'company_type_id': company_type_id if company_type_id else False, @@ -182,7 +192,9 @@ class User(controller.Controller): 'npwp': npwp if is_pkp else (npwp if npwp else '0.000.000.0-000.000'), 'sppkp': sppkp if is_pkp else (sppkp if sppkp else ''), 'nama_wajib_pajak': nama_wajib_pajak, + 'alamat_lengkap_text': alamat_wajib_pajak, 'email': email_partner, + 'street': alamat_bisnis, 'company_type': 'company' } new_company = request.env['res.partner'].create(new_company_data) @@ -191,28 +203,33 @@ class User(controller.Controller): user.partner_id.npwp = new_company.npwp user.partner_id.sppkp = new_company.sppkp user.partner_id.nama_wajib_pajak = new_company.nama_wajib_pajak + user.partner_id.alamat_lengkap_text = new_company.alamat_lengkap_text 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': pdf_data, + 'datas': base64.b64encode(pdf_data), 'res_model': 'res.partner', 'res_id': new_company.id, - 'mimetype': 'application/pdf' + 'mimetype': npwp_mimetype }) new_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': pdf_data, + 'datas': base64.b64encode(pdf_data), 'res_model': 'res.partner', 'res_id': new_company.id, - 'mimetype': 'application/pdf' + 'mimetype': sppkp_mimetype }) new_company.message_post(body="SPPKP Uploaded", attachment_ids=[sppkp_attachment.id]) -- cgit v1.2.3 From 161d234409fa146f8bab98697f568d7a4c1348e1 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 27 Aug 2024 15:14:53 +0700 Subject: update logic code --- indoteknik_api/controllers/api_v1/user.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/indoteknik_api/controllers/api_v1/user.py b/indoteknik_api/controllers/api_v1/user.py index 59684b4c..4a61270f 100644 --- a/indoteknik_api/controllers/api_v1/user.py +++ b/indoteknik_api/controllers/api_v1/user.py @@ -178,19 +178,19 @@ class User(controller.Controller): 'user_input': business_name }) else: - if not nama_wajib_pajak and not is_pkp: + if not nama_wajib_pajak and is_pkp == 'false': nama_wajib_pajak = business_name - if not alamat_wajib_pajak and not is_pkp: + if not alamat_wajib_pajak and is_pkp == 'false': alamat_wajib_pajak = alamat_bisnis new_company_data = { '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, - 'customer_type': 'pkp' if is_pkp else 'nonpkp', - 'npwp': npwp if is_pkp else (npwp if npwp else '0.000.000.0-000.000'), - 'sppkp': sppkp if is_pkp else (sppkp if sppkp else ''), + 'customer_type': 'pkp' if is_pkp == 'true' else 'nonpkp', + 'npwp': npwp if is_pkp == 'true' else (npwp if npwp else '0.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, 'email': email_partner, -- cgit v1.2.3 From 0633f4fa379370de41195e20058e6e671d27b4a9 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 28 Aug 2024 13:14:07 +0700 Subject: update make user individu data --- indoteknik_api/controllers/api_v1/user.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/indoteknik_api/controllers/api_v1/user.py b/indoteknik_api/controllers/api_v1/user.py index 4a61270f..3fb10333 100644 --- a/indoteknik_api/controllers/api_v1/user.py +++ b/indoteknik_api/controllers/api_v1/user.py @@ -108,7 +108,6 @@ class User(controller.Controller): password = kw.get('password') phone = kw.get('phone') - # Form Data # Form Data npwp = kw.get('npwp') npwp_document = kw.get('npwp_document', False) @@ -170,6 +169,11 @@ class User(controller.Controller): if match_ratio > 0.8: # Set the user's partner's parent to the matched company user.partner_id.parent_id = match_company.id + user.partner_id.customer_type = match_company.customer_type + user.partner_id.npwp = match_company.npwp + user.partner_id.sppkp = match_company.sppkp + user.partner_id.nama_wajib_pajak = match_company.nama_wajib_pajak + user.partner_id.alamat_lengkap_text = match_company.alamat_lengkap_text # Create a user company request request.env['user.company.request'].create({ @@ -233,6 +237,11 @@ class User(controller.Controller): }) new_company.message_post(body="SPPKP Uploaded", attachment_ids=[sppkp_attachment.id]) + if type_acc == 'individu': + user.partner_id.customer_type = 'nonpkp' + user.partner_id.npwp = '0.000.000.0-000.000' + user.partner_id.nama_wajib_pajak = name + user.send_activation_mail() response['register'] = True -- cgit v1.2.3 From 4aa0f2612225de32d361547f39283c1529fe955b Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 28 Aug 2024 14:09:05 +0700 Subject: update address fakture --- indoteknik_custom/models/res_partner.py | 40 +++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/indoteknik_custom/models/res_partner.py b/indoteknik_custom/models/res_partner.py index ac126337..6a1257f8 100644 --- a/indoteknik_custom/models/res_partner.py +++ b/indoteknik_custom/models/res_partner.py @@ -58,6 +58,46 @@ class ResPartner(models.Model): default=_default_payment_term ) + @api.depends("street", "street2", "city", "state_id", "country_id", "blok", "nomor", "rt", "rw", "kelurahan_id", + "kecamatan_id") + def _alamat_lengkap(self): + for partner in self: + lengkap = partner.street or "" + lengkap += " " + (partner.street2 or '') + + if partner.blok: + lengkap += " Blok: " + partner.blok + ", " + if partner.nomor: + lengkap += " Nomor: " + partner.nomor + ", " + + if partner.rt: + lengkap += " RT: " + partner.rt + if partner.rw: + lengkap += " RW: " + partner.rw + + if partner.kelurahan_id: + lengkap += " Kel: " + partner.kelurahan_id.name + "," + + if partner.kecamatan_id: + lengkap += " Kec: " + partner.kecamatan_id.name + + if partner.kota_id: + lengkap += """ + """ + partner.kota_id.name + "," + + if partner.state_id: + lengkap += " " + partner.state_id.name + + partner.alamat_lengkap = lengkap.upper() + + if partner.company_type == 'person' and not partner.parent_id: + partner.alamat_lengkap_text = partner.street + else: + partner.alamat_lengkap_text = partner.alamat_lengkap + + alamat_lengkap = fields.Char(string="Alamat Lengkap", required=False, compute="_alamat_lengkap") + alamat_lengkap_text = fields.Text(string="Alamat Lengkap", required=False) + def write(self, vals): res = super(ResPartner, self).write(vals) -- cgit v1.2.3 From cf31bebc38f23450b7c429bb4b3a567515071a40 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 28 Aug 2024 15:30:24 +0700 Subject: update to handle user company request --- indoteknik_api/controllers/api_v1/user.py | 8 -------- indoteknik_custom/models/user_company_request.py | 5 +++++ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/indoteknik_api/controllers/api_v1/user.py b/indoteknik_api/controllers/api_v1/user.py index 3fb10333..bbf1c8d1 100644 --- a/indoteknik_api/controllers/api_v1/user.py +++ b/indoteknik_api/controllers/api_v1/user.py @@ -167,14 +167,6 @@ class User(controller.Controller): if match_company: match_ratio = SequenceMatcher(None, match_company.name, business_name).ratio() if match_ratio > 0.8: - # Set the user's partner's parent to the matched company - user.partner_id.parent_id = match_company.id - user.partner_id.customer_type = match_company.customer_type - user.partner_id.npwp = match_company.npwp - user.partner_id.sppkp = match_company.sppkp - user.partner_id.nama_wajib_pajak = match_company.nama_wajib_pajak - user.partner_id.alamat_lengkap_text = match_company.alamat_lengkap_text - # Create a user company request request.env['user.company.request'].create({ 'user_id': user.partner_id.id, diff --git a/indoteknik_custom/models/user_company_request.py b/indoteknik_custom/models/user_company_request.py index 2467261a..7d28d7ed 100644 --- a/indoteknik_custom/models/user_company_request.py +++ b/indoteknik_custom/models/user_company_request.py @@ -22,6 +22,11 @@ class UserCompanyRequest(models.Model): if not self.is_approve and is_approve: if is_approve == 'approved': self.user_id.parent_id = self.user_company_id.id + self.user_id.customer_type = self.user_company_id.customer_type + self.user_id.npwp = self.user_company_id.npwp + self.user_id.sppkp = self.user_company_id.sppkp + self.user_id.nama_wajib_pajak = self.user_company_id.nama_wajib_pajak + self.user_id.alamat_lengkap_text = self.user_company_id.alamat_lengkap_text else: new_company = self.env['res.partner'].create({ 'name': self.user_input -- cgit v1.2.3 From 04a39b785c2e3feef390d46e498e27289a10ffb4 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 28 Aug 2024 15:59:17 +0700 Subject: update user active false --- indoteknik_api/controllers/api_v1/user.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_api/controllers/api_v1/user.py b/indoteknik_api/controllers/api_v1/user.py index bbf1c8d1..13a0a293 100644 --- a/indoteknik_api/controllers/api_v1/user.py +++ b/indoteknik_api/controllers/api_v1/user.py @@ -149,7 +149,7 @@ class User(controller.Controller): 'login': email, 'phone': phone, 'password': password, - 'active': True, + 'active': False, 'sel_groups_1_9_10': 9 } -- cgit v1.2.3 From 09ff6a7ea7860698c736afd926b7d249b1509de9 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 29 Aug 2024 13:37:13 +0700 Subject: update phone number missing at web --- indoteknik_api/controllers/api_v1/user.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/indoteknik_api/controllers/api_v1/user.py b/indoteknik_api/controllers/api_v1/user.py index 13a0a293..4e20e2c8 100644 --- a/indoteknik_api/controllers/api_v1/user.py +++ b/indoteknik_api/controllers/api_v1/user.py @@ -147,7 +147,7 @@ class User(controller.Controller): user_data = { 'name': name, 'login': email, - 'phone': phone, + 'mobile': phone, 'password': password, 'active': False, 'sel_groups_1_9_10': 9 @@ -155,7 +155,7 @@ class User(controller.Controller): user = request.env['res.users'].create(user_data) user.partner_id.email = email - user.partner_id.phone = phone + user.partner_id.mobile = phone if type_acc == 'business': parameter = [ -- cgit v1.2.3 From c3d6ea4ae3ce658a2b01b3b79561d6ebf15f41ef Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 30 Aug 2024 11:05:04 +0700 Subject: ubah format npwp dan sppkp --- indoteknik_api/controllers/api_v1/user.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/indoteknik_api/controllers/api_v1/user.py b/indoteknik_api/controllers/api_v1/user.py index 4e20e2c8..61bb4425 100644 --- a/indoteknik_api/controllers/api_v1/user.py +++ b/indoteknik_api/controllers/api_v1/user.py @@ -185,8 +185,8 @@ class User(controller.Controller): 'company_type_id': company_type_id if company_type_id else False, 'industry_id': industry_id, 'customer_type': 'pkp' if is_pkp == 'true' else 'nonpkp', - 'npwp': npwp if is_pkp == 'true' else (npwp if npwp else '0.000.000.0-000.000'), - 'sppkp': sppkp if is_pkp == 'true' else (sppkp if sppkp else ''), + '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, 'email': email_partner, -- cgit v1.2.3 From 6d90f84246b1c6ef01b3ba3f1231450b11862719 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 30 Aug 2024 11:52:21 +0700 Subject: udate new register --- indoteknik_api/controllers/api_v1/user.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/indoteknik_api/controllers/api_v1/user.py b/indoteknik_api/controllers/api_v1/user.py index 61bb4425..1f9c077e 100644 --- a/indoteknik_api/controllers/api_v1/user.py +++ b/indoteknik_api/controllers/api_v1/user.py @@ -191,15 +191,26 @@ class User(controller.Controller): 'alamat_lengkap_text': alamat_wajib_pajak, 'email': email_partner, 'street': alamat_bisnis, - 'company_type': 'company' + 'company_type': 'company', + 'user_id': 3222, + 'property_account_receivable_id': 395, + 'property_account_payable_id': 438, + 'active_limit': True, + 'warning_stage': 4000000, + # 'blocking_stage': 5000000, } new_company = request.env['res.partner'].create(new_company_data) - user.partner_id.parent_id = new_company.id - user.partner_id.customer_type = new_company.customer_type - user.partner_id.npwp = new_company.npwp - user.partner_id.sppkp = new_company.sppkp - user.partner_id.nama_wajib_pajak = new_company.nama_wajib_pajak - user.partner_id.alamat_lengkap_text = new_company.alamat_lengkap_text + request.env['user.company.request'].create({ + 'user_id': user.partner_id.id, + 'user_company_id': new_company.id, + 'user_input': business_name + }) + # user.partner_id.parent_id = new_company.id + # user.partner_id.customer_type = new_company.customer_type + # user.partner_id.npwp = new_company.npwp + # user.partner_id.sppkp = new_company.sppkp + # user.partner_id.nama_wajib_pajak = new_company.nama_wajib_pajak + # user.partner_id.alamat_lengkap_text = new_company.alamat_lengkap_text if npwp_document: npwp_mimetype, _ = mimetypes.guess_type(npwp_filename) @@ -232,6 +243,7 @@ class User(controller.Controller): if type_acc == 'individu': user.partner_id.customer_type = 'nonpkp' user.partner_id.npwp = '0.000.000.0-000.000' + user.partner_id.sppkp = '-' user.partner_id.nama_wajib_pajak = name user.send_activation_mail() -- cgit v1.2.3 From edafc890045d833289ad3b53ce3375625f18e54c Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 30 Aug 2024 14:59:50 +0700 Subject: update jika sppkp diganti di order, parent sppkp juga terganti --- indoteknik_api/controllers/api_v1/sale_order.py | 11 +++++--- indoteknik_custom/models/sale_order.py | 35 +++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/indoteknik_api/controllers/api_v1/sale_order.py b/indoteknik_api/controllers/api_v1/sale_order.py index a50cb264..7edd71f6 100644 --- a/indoteknik_api/controllers/api_v1/sale_order.py +++ b/indoteknik_api/controllers/api_v1/sale_order.py @@ -378,6 +378,9 @@ class SaleOrder(controller.Controller): if not params['valid']: return self.response(code=400, description=params) + # Fetch partner details + sales_partner = request.env['res.partner'].browse(params['value']['partner_id']) + parameters = { 'warehouse_id': 8, 'carrier_id': 1, @@ -405,9 +408,11 @@ class SaleOrder(controller.Controller): 'delivery_service_type': params['value']['delivery_service_type'], 'flash_sale': params['value']['flash_sale'], 'note_website': params['value']['note_website'], - 'customer_type': 'nonpkp', - 'npwp': '0', - 'user_id': 3222 # User ID: Nadia Rauhadatul Firdaus + 'customer_type': sales_partner.customer_type if sales_partner else 'nonpkp', # Get Customer Type from partner + 'npwp': sales_partner.npwp or '0', # Get NPWP from partner + 'sppkp': sales_partner.sppkp, # Get SPPKP from partner + 'email': sales_partner.email, # Get Email from partner + 'user_id': 3222 # User ID: Nadia Rauhadatul Firdaus } sales_partner = request.env['res.partner'].browse(parameters['partner_id']) diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 710e99de..16a1f415 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -942,3 +942,38 @@ class SaleOrder(models.Model): order_line.tax_id = tax_id order_line.discount = discount order_line.order_id.use_button = True + + @api.model + def create(self, vals): + # Ensure partner details are updated when a sale order is created + order = super(SaleOrder, self).create(vals) + order._update_partner_details() + return order + + def write(self, vals): + # Call the super method to handle the write operation + res = super(SaleOrder, self).write(vals) + + # Check if the update is coming from a save operation + if any(field in vals for field in ['sppkp', 'npwp', 'email', 'customer_type']): + self._update_partner_details() + + return res + + def _update_partner_details(self): + for order in self: + partner = order.partner_id.parent_id or order.partner_id + if partner: + # Update partner details + partner.sppkp = order.sppkp + partner.npwp = order.npwp + partner.email = order.email + partner.customer_type = order.customer_type + + # Save changes to the partner record + partner.write({ + 'sppkp': partner.sppkp, + 'npwp': partner.npwp, + 'email': partner.email, + 'customer_type': partner.customer_type, + }) \ No newline at end of file -- cgit v1.2.3 From 0801de741384b29a01f5570f420da10953834e22 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 30 Aug 2024 16:13:46 +0700 Subject: update automatic data new register --- indoteknik_api/controllers/api_v1/user.py | 3 +++ indoteknik_custom/models/user_company_request.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/indoteknik_api/controllers/api_v1/user.py b/indoteknik_api/controllers/api_v1/user.py index 1f9c077e..a8b1a3eb 100644 --- a/indoteknik_api/controllers/api_v1/user.py +++ b/indoteknik_api/controllers/api_v1/user.py @@ -245,6 +245,9 @@ class User(controller.Controller): user.partner_id.npwp = '0.000.000.0-000.000' user.partner_id.sppkp = '-' user.partner_id.nama_wajib_pajak = name + user.partner_id.user_id = 3222 + user.partner_id.property_account_receivable_id= 395 + user.partner_id.property_account_payable_id = 438 user.send_activation_mail() diff --git a/indoteknik_custom/models/user_company_request.py b/indoteknik_custom/models/user_company_request.py index 7d28d7ed..69067e9c 100644 --- a/indoteknik_custom/models/user_company_request.py +++ b/indoteknik_custom/models/user_company_request.py @@ -27,6 +27,9 @@ class UserCompanyRequest(models.Model): self.user_id.sppkp = self.user_company_id.sppkp self.user_id.nama_wajib_pajak = self.user_company_id.nama_wajib_pajak self.user_id.alamat_lengkap_text = self.user_company_id.alamat_lengkap_text + self.user_id.user_id = self.user_company_id.user_id + self.user_id.property_account_receivable_id = self.user_company_id.property_account_receivable_id + self.user_id.property_account_payable_id = self.user_company_id.property_account_payable_id else: new_company = self.env['res.partner'].create({ 'name': self.user_input -- cgit v1.2.3 From dfc764a3f3b2adb9526740342ada58ed4ddfcb11 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 30 Aug 2024 16:41:49 +0700 Subject: update new register --- indoteknik_api/controllers/api_v1/user.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/indoteknik_api/controllers/api_v1/user.py b/indoteknik_api/controllers/api_v1/user.py index a8b1a3eb..6300eb86 100644 --- a/indoteknik_api/controllers/api_v1/user.py +++ b/indoteknik_api/controllers/api_v1/user.py @@ -195,9 +195,6 @@ class User(controller.Controller): 'user_id': 3222, 'property_account_receivable_id': 395, 'property_account_payable_id': 438, - 'active_limit': True, - 'warning_stage': 4000000, - # 'blocking_stage': 5000000, } new_company = request.env['res.partner'].create(new_company_data) request.env['user.company.request'].create({ -- cgit v1.2.3 From 9ee856d603530e8cc3494a2bccb8fdfaa328da6a Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 3 Sep 2024 14:14:09 +0700 Subject: push --- indoteknik_api/controllers/api_v1/cart.py | 23 +++++++++++++++++++---- indoteknik_custom/models/sale_order.py | 9 +++++++++ indoteknik_custom/models/stock_picking.py | 19 +++++++++++++++++-- indoteknik_custom/views/sale_order.xml | 5 +++++ 4 files changed, 50 insertions(+), 6 deletions(-) diff --git a/indoteknik_api/controllers/api_v1/cart.py b/indoteknik_api/controllers/api_v1/cart.py index f472a9b0..a2fd6286 100644 --- a/indoteknik_api/controllers/api_v1/cart.py +++ b/indoteknik_api/controllers/api_v1/cart.py @@ -17,10 +17,25 @@ class Cart(controller.Controller): query = [('user_id', '=', user_id)] carts = user_cart.search(query, limit=limit, offset=offset, order='create_date desc') carts.write({'source': 'add_to_cart'}) - data = { - 'product_total': user_cart.search_count(query), - 'products': carts.with_context(price_for="web").get_products() - } + data = [] + for cart in carts: + if cart.product_id: + price = cart.product_id._v2_get_website_price_include_tax() + if cart.product_id.active and price > 0: + data.append({ + 'products': cart.with_context(price_for="web").get_products() + }) + else: + data.append({ + 'product_inactive': cart.with_context(price_for="web").get_products() + }) + else: + data.append({ + 'products': cart.with_context(price_for="web").get_products() + }) + data.append({ + 'product_total': user_cart.search_count(query) + }) return self.response(data) @http.route(PREFIX_USER + 'cart/count', auth='public', methods=['GET', 'OPTIONS']) diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 710e99de..2769d408 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -109,6 +109,15 @@ class SaleOrder(models.Model): date_driver_departure = fields.Datetime(string='Departure Date', compute='_compute_date_kirim', copy=False) note_website = fields.Char(string="Note Website") use_button = fields.Boolean(string='Using Calculate Selling Price', copy=False) + unreserve_id = fields.Many2one('stock.picking', 'Unreserve Picking') + + def do_unreserve(self): + user_id = self.env.user.id + if user_id != self.user_id.id: + raise UserError(_("Only the user who created the picking can unreserve it.")) + + self.unreserve_id.do_unreserve() + def _compute_date_kirim(self): for rec in self: diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index d16d508e..474c7526 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -125,12 +125,27 @@ class StockPicking(models.Model): raise UserError('Hanya Logistic yang bisa mengubah shipping method') def do_unreserve(self): + if self.sale_id.unreserve_id.id != self.id: + self.sale_id.unreserve_id = self.id + return self._create_approval_notification('Logistic') + res = super(StockPicking, self).do_unreserve() - if not self.env.user.is_purchasing_manager: - raise UserError('Hanya Purchasing Manager yang bisa Unreserve') current_time = datetime.datetime.utcnow() self.date_unreserve = current_time + return res + + def _create_approval_notification(self, approval_role): + title = 'Warning' + message = f'Butuh approval sales untuk unreserved' + return self._create_notification_action(title, message) + + def _create_notification_action(self, title, message): + return { + 'type': 'ir.actions.client', + 'tag': 'display_notification', + 'params': { 'title': title, 'message': message, 'next': {'type': 'ir.actions.act_window_close'} }, + } def _compute_shipping_status(self): for rec in self: diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml index 1257ff85..569c59f3 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -11,6 +11,10 @@ string="Create No" type="object" /> + + @@ -88,6 +91,7 @@ + -- cgit v1.2.3 From b61d191e9d5663acb81338de133789fd0c43bdf0 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 10 Sep 2024 16:10:15 +0700 Subject: add payment terms on users --- indoteknik_custom/models/res_users.py | 1 + 1 file changed, 1 insertion(+) diff --git a/indoteknik_custom/models/res_users.py b/indoteknik_custom/models/res_users.py index 33f64ce3..70a7dc53 100755 --- a/indoteknik_custom/models/res_users.py +++ b/indoteknik_custom/models/res_users.py @@ -11,6 +11,7 @@ class ResUsers(models.Model): activation_token = fields.Char(string="Activation Token") otp_code = fields.Char(string='OTP Code') otp_create_date = fields.Datetime(string='OTP Create Date') + payment_terms_id = fields.Many2one('account.payment.term', related='partner_id.property_payment_term_id', string='Payment Terms') def _generate_otp(self): for user in self: -- cgit v1.2.3 From 1371df38b6818960e6e9520ae783f041694209d8 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 11 Sep 2024 13:39:13 +0700 Subject: ongkos kirim po --- indoteknik_custom/models/purchase_order.py | 13 +++++++++++++ indoteknik_custom/views/purchase_order.xml | 6 +++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 83e401b7..edcbbb19 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -31,6 +31,7 @@ class PurchaseOrder(models.Model): ('approved', 'Approved'), ], string='Approval Status', readonly=True, copy=False, index=True, tracking=3) delivery_amount = fields.Float('Delivery Amount', compute='compute_delivery_amount') + delivery_amt = fields.Float('Delivery Amt') total_margin = fields.Float( 'Margin', compute='compute_total_margin', help="Total Margin in Sales Order Header") @@ -67,6 +68,14 @@ class PurchaseOrder(models.Model): ], string='Printed?', copy=False, tracking=True) date_done_picking = fields.Datetime(string='Date Done Picking', compute='get_date_done') bills_dp_id = fields.Many2one('account.move', string='Bills DP') + grand_total = fields.Monetary(string='Grand Total', help='Amount total + amount delivery', compute='_compute_grand_total') + + def _compute_grand_total(self): + for order in self: + if order.delivery_amt: + order.grand_total = order.delivery_amt + order.amount_total + else: + order.grand_total = order.amount_total def create_bill_dp(self): if not self.env.user.is_accounting: @@ -671,6 +680,8 @@ class PurchaseOrder(models.Model): purchase_price = line.price_subtotal if line.order_id.delivery_amount > 0: purchase_price += line.delivery_amt_line + if line.order_id.delivery_amt > 0: + purchase_price += line.order_id.delivery_amt real_item_margin = sales_price - purchase_price sum_margin += real_item_margin @@ -713,6 +724,8 @@ class PurchaseOrder(models.Model): purchase_price = po_line.price_subtotal / po_line.product_qty * line.qty_po if line.purchase_order_id.delivery_amount > 0: purchase_price += (po_line.delivery_amt_line / po_line.product_qty) * line.qty_po + if line.purchase_order_id.delivery_amt > 0: + purchase_price += line.purchase_order_id.delivery_amt real_item_margin = sales_price - purchase_price sum_margin += real_item_margin diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml index 9ded8308..6bc97bbf 100755 --- a/indoteknik_custom/views/purchase_order.xml +++ b/indoteknik_custom/views/purchase_order.xml @@ -37,7 +37,10 @@ - + + + + @@ -45,6 +48,7 @@ + -- cgit v1.2.3 From 9f929b654279badc9b9f4c632a6a962903c24d6d Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 11 Sep 2024 14:13:11 +0700 Subject: cr report purchase order --- indoteknik_custom/report/purchase_order.xml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/indoteknik_custom/report/purchase_order.xml b/indoteknik_custom/report/purchase_order.xml index 0f392630..98af3188 100644 --- a/indoteknik_custom/report/purchase_order.xml +++ b/indoteknik_custom/report/purchase_order.xml @@ -11,5 +11,21 @@

+ + + Delivery Amt + + + + + + Grand Total + + + + + -- cgit v1.2.3 From d8e60a974097058482167eefe658f9b4e89c0dd2 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Wed, 11 Sep 2024 16:07:56 +0700 Subject: mandatory delivery date --- indoteknik_custom/models/sale_order.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index b6759306..5e792b05 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -633,6 +633,9 @@ class SaleOrder(models.Model): if not order.client_order_ref and order.create_date > datetime(2024, 6, 27): raise UserError("Customer Reference kosong, di isi dengan NO PO jika PO tidak ada mohon ditulis Tanpa PO") + + if not order.commitment_date and order.create_date > datetime(2024, 9, 10): + raise UserError("Expected Delivery Date kosong, wajib diisi") if order.validate_partner_invoice_due(): return self._create_notification_action('Notification', 'Terdapat invoice yang telah melewati batas waktu, mohon perbarui pada dokumen Due Extension') -- cgit v1.2.3 From a8e539c92236453ce7aad06d23cf117f4b7239fc Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Wed, 11 Sep 2024 16:08:30 +0700 Subject: revise --- indoteknik_custom/models/sale_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 5e792b05..9506aedb 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -634,7 +634,7 @@ class SaleOrder(models.Model): if not order.client_order_ref and order.create_date > datetime(2024, 6, 27): raise UserError("Customer Reference kosong, di isi dengan NO PO jika PO tidak ada mohon ditulis Tanpa PO") - if not order.commitment_date and order.create_date > datetime(2024, 9, 10): + if not order.commitment_date and order.create_date > datetime(2024, 9, 12): raise UserError("Expected Delivery Date kosong, wajib diisi") if order.validate_partner_invoice_due(): -- cgit v1.2.3 From 82f0467cd3f014761fd35bd04eecc485ed8addda Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 12 Sep 2024 09:46:14 +0700 Subject: push --- indoteknik_custom/models/sale_order.py | 7 +++++-- indoteknik_custom/views/sale_order.xml | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index d389f6ae..abfbb799 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -113,10 +113,13 @@ class SaleOrder(models.Model): def do_unreserve(self): user_id = self.env.user.id - if user_id != self.user_id.id: + if user_id != self.user_id.id and user_id != self.helper_by_id.id: raise UserError(_("Only the user who created the picking can unreserve it.")) - self.unreserve_id.with_context({'darimana': 'sale.order'}).do_unreserve() + if self.unreserve_id and self.unreserve_id.state == 'assigned': + self.unreserve_id.with_context({'darimana': 'sale.order'}).do_unreserve() + else: + raise UserError(_("Picking not found.")) def _compute_date_kirim(self): for rec in self: diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml index 54c01594..68116544 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -14,7 +14,7 @@