From eb7661705303a64c97e84061b53d48d5c46f6293 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 19 Sep 2024 15:08:15 +0700 Subject: add email user company request status --- indoteknik_api/controllers/api_v1/user.py | 9 ++ indoteknik_custom/models/res_users.py | 19 ++- indoteknik_custom/models/user_company_request.py | 13 +- indoteknik_custom/views/res_users.xml | 197 ++++++++++++++++++++++- 4 files changed, 234 insertions(+), 4 deletions(-) diff --git a/indoteknik_api/controllers/api_v1/user.py b/indoteknik_api/controllers/api_v1/user.py index 4dfc837b..87d6cafc 100644 --- a/indoteknik_api/controllers/api_v1/user.py +++ b/indoteknik_api/controllers/api_v1/user.py @@ -329,6 +329,15 @@ class User(controller.Controller): 'activation': True, 'user': self.response_with_token(user) }) + # tambahkan send email ke user untuk kasi notifikasi akun bisnis ini dalam review + parameter = [ + ('user_id', '=', user.partner_id.id) + ] + company_request = request.env['user.company.request'].search(parameter, limit=1) + if company_request: + user.user_company_name = company_request.user_input + if company_request.is_approve == False: + user.send_company_request_mail() return self.response(response) @http.route(prefix + 'user/forgot-password', auth='public', methods=['POST'], csrf=False) diff --git a/indoteknik_custom/models/res_users.py b/indoteknik_custom/models/res_users.py index 33f64ce3..cedf19bd 100755 --- a/indoteknik_custom/models/res_users.py +++ b/indoteknik_custom/models/res_users.py @@ -11,6 +11,8 @@ 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') + user_company_name = fields.Char(string="User Company Name") + def _generate_otp(self): for user in self: @@ -28,7 +30,22 @@ class ResUsers(models.Model): user._generate_otp() user._generate_activation_token() template.send_mail(user.id, force_send=True) - + + def send_company_request_mail(self): + template = self.env.ref('indoteknik_custom.mail_template_res_user_company_request') + for user in self: + template.send_mail(user.id, force_send=True) + + def send_company_request_approve_mail(self): + template = self.env.ref('indoteknik_custom.mail_template_res_user_company_request_approve') + for user in self: + template.send_mail(user.id, force_send=True) + + def send_company_request_reject_mail(self): + template = self.env.ref('indoteknik_custom.mail_template_res_user_company_request_reject') + for user in self: + template.send_mail(user.id, force_send=True) + def get_activation_token_url(self): base_url = self.env['ir.config_parameter'].get_param('site.base.url') return f'{base_url}/register?activation=token&token={self.activation_token}' diff --git a/indoteknik_custom/models/user_company_request.py b/indoteknik_custom/models/user_company_request.py index 40ac4446..8122c6a0 100644 --- a/indoteknik_custom/models/user_company_request.py +++ b/indoteknik_custom/models/user_company_request.py @@ -1,6 +1,6 @@ from odoo import models, fields from odoo.exceptions import UserError - +from odoo.http import request class UserCompanyRequest(models.Model): _name = 'user.company.request' @@ -15,6 +15,8 @@ class UserCompanyRequest(models.Model): ], string='Approval') def write(self, vals): + user = self.get_user_by_email(self.user_id.email) + user.user_company_name = self.user_input is_approve = vals.get('is_approve') if self.is_approve and is_approve: raise UserError('Tidak dapat mengubah approval yang sudah diisi') @@ -34,11 +36,18 @@ class UserCompanyRequest(models.Model): self.user_id.property_account_payable_id = self.user_company_id.property_account_payable_id self.user_company_id.active = True # tambahkan send email kalau bisnis berhsil di buat + user.send_company_request_approve_mail() else: new_company = self.env['res.partner'].create({ 'name': self.user_input }) self.user_id.parent_id = new_company.id # tambahkan send email kalau bisnis ditolak di buat + user.send_company_request_reject_mail() return super(UserCompanyRequest, self).write(vals) - \ No newline at end of file + + def get_user_by_email(self, email): + return request.env['res.users'].search([ + ('login', '=', email), + ('active', 'in', [True, False]) + ]) \ No newline at end of file diff --git a/indoteknik_custom/views/res_users.xml b/indoteknik_custom/views/res_users.xml index 976f46c9..8ced0e82 100644 --- a/indoteknik_custom/views/res_users.xml +++ b/indoteknik_custom/views/res_users.xml @@ -4,7 +4,8 @@ Users: Activation Request Aktivasi Akun - Indoteknik.com - sales@indoteknik.com + "Indoteknik.com" <noreply@indoteknik.com> + noreply@indoteknik.com ${object.login | safe} @@ -59,5 +60,199 @@
+ + Users: Company Request + + Email Pendaftaran Bisnis dalam Proses Review + "Indoteknik.com" <noreply@indoteknik.com> + noreply@indoteknik.com + ${object.login | safe} + + + +
+ + + + + + + + + + + + +
+ + + + + + + + +
+ +
+
+
+
+ + + + + + + + + + + + + + +
Halo ${object.user_company_name},
Terima kasih atas kepercayaan Anda dengan mendaftarkan bisnis Anda di Indoteknik.com. Permohonan Anda saat ini sedang dalam proses review oleh tim kami.
Saat ini, kami sedang melakukan pengecekan akhir pada data yang Anda berikan. Proses ini biasanya memakan waktu sekitar 2 x 24 jam.
Setelah proses review selesai, kami akan segera menginformasikan status akun bisnis Anda melalui email.
Jika ada pertanyaan lebih lanjut, jangan ragu untuk menghubungi kami di sales@indoteknik.com atau hubungi whatsapp kami di 0817-1718-1922
Terima kasih atas perhatiannya.
Hormat kami,
Indoteknik.com
+
+
+
+
+
+
+ + Users: Company Request Approve + + Email Pendaftaran Bisnis Berhasil + "Indoteknik.com" <noreply@indoteknik.com> + noreply@indoteknik.com + ${object.login | safe} + + + +
+ + + + + + + + + + + + +
+ + + + + + + + +
+ +
+
+
+
+ + + + + + + + + + + + + + + +
Yth. ${object.user_company_name},
Selamat! Pendaftaran akun bisnis Anda di indoteknik.com telah berhasil diverifikasi & sudah aktif. kini anda dapat menikmati berbagai kemudahan dalam berbelanja, antara lain:
Fitur Faktur Pajak & Invoice: Dengan mudah download faktur pajak & Invoice Anda secara digital.
Pembayaran Lengkap: Pilih metode pembayaran yang sesuai dengan kebutuhan Anda, baik transfer bank, VA, kartu kredit, atau pembayaran tempo.
Pelacakan Pengiriman: Lacak status pengiriman pesanan Anda secara real-time.
Untuk memulai transaksi, silakan login Kembali menggunakan akun Anda di Indoteknik.com
Kami sangat senang dapat melayani Anda. Jika ada pertanyaan atau membutuhkan bantuan, jangan ragu untuk menghubungi tim layanan Customer kami di Whatsapp 0817-1718-1922 atau sales@indoteknik.com
Hormat kami,
Indoteknik.com
+
+
+
+
+
+
+ + Users: Company Request Reject + + Email Pendaftaran Bisnis Tidak Berhasil + "Indoteknik.com" <noreply@indoteknik.com> + noreply@indoteknik.com + ${object.login | safe} + + + +
+ + + + + + + + + + + + +
+ + + + + + + + +
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + +
Yth. ${object.user_company_name},
Terima kasih atas minat Anda untuk mendaftar akun bisnis di Indoteknik.com. Kami telah menerima permohonan pendaftaran Anda dan saat ini sedang dalam proses review.
Namun, setelah kami lakukan pengecekan, kami menemukan bahwa beberapa informasi yang Anda berikan masih belum lengkap. Untuk dapat melanjutkan proses pendaftaran, mohon kiranya Anda dapat melengkapi data-data berikut:
Informasi yang kami butuhkan saat ini adalah:
+
    +
  1. Detail Nama Bisnis
  2. +
  3. Dokumen NPWP
  4. +
  5. Dokumen SPPKP/Surat Pengukuhan Kena Pajak
  6. +
+
Anda dapat mengirimkan informasi yang kurang tersebut melalui email ini atau dengan menghubungi tim layanan pelanggan kami di 0817-1718-1922 atau sales@indoteknik.com.
Kami mohon maaf atas ketidaknyamanan ini dan berharap dapat segera menyelesaikan proses pendaftaran akun bisnis Anda.
Terima kasih atas perhatiannya.
Hormat kami,
Indoteknik.com
+
+
+
+
+
+
\ No newline at end of file -- cgit v1.2.3