summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2024-09-19 15:08:15 +0700
committerit-fixcomart <it@fixcomart.co.id>2024-09-19 15:08:15 +0700
commiteb7661705303a64c97e84061b53d48d5c46f6293 (patch)
tree45bf036c171e6855747ce5f6ce697bd0dcf24a3b
parentc1d1b273e2eeb3c4713fe174846ec7687ec2026b (diff)
<iman> add email user company request status
-rw-r--r--indoteknik_api/controllers/api_v1/user.py9
-rwxr-xr-xindoteknik_custom/models/res_users.py19
-rw-r--r--indoteknik_custom/models/user_company_request.py13
-rw-r--r--indoteknik_custom/views/res_users.xml197
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&amp;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 @@
<field name="name">Users: Activation Request</field>
<field name="model_id" ref="base.model_res_users"/>
<field name="subject">Aktivasi Akun - Indoteknik.com</field>
- <field name="email_from">sales@indoteknik.com</field>
+ <field name="email_from">"Indoteknik.com" &lt;noreply@indoteknik.com&gt;</field>
+ <field name="reply_to">noreply@indoteknik.com</field>
<field name="email_to">${object.login | safe}</field>
<field name="body_html" type="html">
<table border="0" cellpadding="0" cellspacing="0" style="padding-top: 16px; background-color: #F1F1F1; font-family:Inter, Helvetica, Verdana, Arial,sans-serif; line-height: 24px; color: #454748; width: 100%; border-collapse:separate;">
@@ -59,5 +60,199 @@
</table>
</field>
</record>
+ <record id="mail_template_res_user_company_request" model="mail.template">
+ <field name="name">Users: Company Request</field>
+ <field name="model_id" ref="base.model_res_users"/>
+ <field name="subject">Email Pendaftaran Bisnis dalam Proses Review</field>
+ <field name="email_from">"Indoteknik.com" &lt;noreply@indoteknik.com&gt;</field>
+ <field name="reply_to">noreply@indoteknik.com</field>
+ <field name="email_to">${object.login | safe}</field>
+ <field name="body_html" type="html">
+ <table border="0" cellpadding="0" cellspacing="0" style="padding-top: 16px; background-color: #F1F1F1; font-family:Inter, Helvetica, Verdana, Arial,sans-serif; line-height: 24px; color: #454748; width: 100%; border-collapse:separate;">
+ <tr><td align="center">
+ <table border="0" cellpadding="0" cellspacing="0" width="590" style="font-size: 13px; padding: 16px; background-color: white; color: #454748; border-collapse:separate;">
+ <!-- HEADER -->
+ <tbody>
+ <tr>
+ <td align="center" style="min-width: 590px;">
+ <table border="0" cellpadding="0" cellspacing="0" width="590" style="min-width: 590px; background-color: white; padding: 0px 8px 0px 8px; border-collapse:separate;">
+ <tr>
+ <td valign="middle">
+ <span></span>
+ </td>
+ </tr>
+
+ <tr>
+ <td colspan="2" style="text-align:center;">
+ <hr width="100%" style="background-color:rgb(204,204,204);border:medium none;clear:both;display:block;font-size:0px;min-height:1px;line-height:0; margin: 16px 0px 16px 0px;" />
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <!-- CONTENT -->
+ <tr>
+ <td align="center" style="min-width: 590px;">
+ <table border="0" cellpadding="0" cellspacing="0" width="590" style="min-width: 590px; background-color: white; padding: 0px 8px 0px 8px; border-collapse:separate;">
+ <tr><td style="padding-bottom: 24px;"><b>Halo ${object.user_company_name},</b></td></tr>
+
+ <tr><td style="padding-bottom: 16px;">Terima kasih atas kepercayaan Anda dengan mendaftarkan bisnis Anda di Indoteknik.com. Permohonan Anda saat ini sedang dalam proses review oleh tim kami.</td></tr>
+ <tr><td style="padding-bottom: 16px;">Saat ini, kami sedang melakukan pengecekan akhir pada data yang Anda berikan. Proses ini biasanya memakan waktu sekitar 2 x 24 jam.</td></tr>
+ <tr><td style="padding-bottom: 16px;">Setelah proses review selesai, kami akan segera menginformasikan status akun bisnis Anda melalui email.</td></tr>
+ <tr><td style="padding-bottom: 16px;">Jika ada pertanyaan lebih lanjut, jangan ragu untuk menghubungi kami di <a href="mailto:sales@indoteknik.com">sales@indoteknik.com</a> atau hubungi whatsapp kami di <a href="https://wa.me/6281717181922">0817-1718-1922</a></td></tr>
+ <tr><td style="padding-bottom: 16px;">Terima kasih atas perhatiannya.</td></tr>
+
+ <tr><td style="padding-bottom: 2px;"><strong>Hormat kami,</strong></td></tr>
+ <tr><td style="padding-bottom: 2px;">Indoteknik.com</td></tr>
+ <tr>
+ <td style="text-align:center;">
+ <hr width="100%"
+ style="background-color:rgb(204,204,204);border:medium none;clear:both;display:block;font-size:0px;min-height:1px;line-height:0; margin: 16px 0px 16px 0px;" />
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <!-- CONTENT -->
+ </tbody>
+ </table>
+ </td></tr>
+ </table>
+ </field>
+ </record>
+ <record id="mail_template_res_user_company_request_approve" model="mail.template">
+ <field name="name">Users: Company Request Approve</field>
+ <field name="model_id" ref="base.model_res_users"/>
+ <field name="subject">Email Pendaftaran Bisnis Berhasil</field>
+ <field name="email_from">"Indoteknik.com" &lt;noreply@indoteknik.com&gt;</field>
+ <field name="reply_to">noreply@indoteknik.com</field>
+ <field name="email_to">${object.login | safe}</field>
+ <field name="body_html" type="html">
+ <table border="0" cellpadding="0" cellspacing="0" style="padding-top: 16px; background-color: #F1F1F1; font-family:Inter, Helvetica, Verdana, Arial,sans-serif; line-height: 24px; color: #454748; width: 100%; border-collapse:separate;">
+ <tr><td align="center">
+ <table border="0" cellpadding="0" cellspacing="0" width="590" style="font-size: 13px; padding: 16px; background-color: white; color: #454748; border-collapse:separate;">
+ <!-- HEADER -->
+ <tbody>
+ <tr>
+ <td align="center" style="min-width: 590px;">
+ <table border="0" cellpadding="0" cellspacing="0" width="590" style="min-width: 590px; background-color: white; padding: 0px 8px 0px 8px; border-collapse:separate;">
+ <tr>
+ <td valign="middle">
+ <span></span>
+ </td>
+ </tr>
+
+ <tr>
+ <td colspan="2" style="text-align:center;">
+ <hr width="100%" style="background-color:rgb(204,204,204);border:medium none;clear:both;display:block;font-size:0px;min-height:1px;line-height:0; margin: 16px 0px 16px 0px;" />
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <!-- CONTENT -->
+ <tr>
+ <td align="center" style="min-width: 590px;">
+ <table border="0" cellpadding="0" cellspacing="0" width="590" style="min-width: 590px; background-color: white; padding: 0px 8px 0px 8px; border-collapse:separate;">
+ <tr><td style="padding-bottom: 24px;"><b>Yth. ${object.user_company_name},</b></td></tr>
+
+ <tr><td style="padding-bottom: 16px;">Selamat! Pendaftaran akun bisnis Anda di indoteknik.com telah <b>berhasil diverifikasi &amp; sudah aktif.</b> kini anda dapat menikmati berbagai kemudahan dalam berbelanja, antara lain:</td></tr>
+ <tr><td style="padding-bottom: 16px;"><b>Fitur Faktur Pajak &amp; Invoice:</b> Dengan mudah download faktur pajak &amp; Invoice Anda secara digital.</td></tr>
+ <tr><td style="padding-bottom: 16px;"><b>Pembayaran Lengkap:</b> Pilih metode pembayaran yang sesuai dengan kebutuhan Anda, baik transfer bank, VA, kartu kredit, atau pembayaran tempo.</td></tr>
+ <tr><td style="padding-bottom: 16px;"><b>Pelacakan Pengiriman:</b> Lacak status pengiriman pesanan Anda secara real-time.</td></tr>
+ <tr><td style="padding-bottom: 16px;">Untuk memulai transaksi, silakan login Kembali menggunakan akun Anda di <a href="https://indoteknik.com/login">Indoteknik.com</a></td></tr>
+ <tr><td style="padding-bottom: 16px;">Kami sangat senang dapat melayani Anda. Jika ada pertanyaan atau membutuhkan bantuan, jangan ragu untuk menghubungi tim layanan Customer kami di Whatsapp <a href="https://wa.me/6281717181922">0817-1718-1922</a> atau <a href="mailto:sales@indoteknik.com">sales@indoteknik.com</a></td></tr>
+
+ <tr><td style="padding-bottom: 2px;"><b>Hormat kami,</b></td></tr>
+ <tr><td style="padding-bottom: 2px;">Indoteknik.com</td></tr>
+ <tr>
+ <td style="text-align:center;">
+ <hr width="100%"
+ style="background-color:rgb(204,204,204);border:medium none;clear:both;display:block;font-size:0px;min-height:1px;line-height:0; margin: 16px 0px 16px 0px;" />
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <!-- CONTENT -->
+ </tbody>
+ </table>
+ </td></tr>
+ </table>
+ </field>
+ </record>
+ <record id="mail_template_res_user_company_request_reject" model="mail.template">
+ <field name="name">Users: Company Request Reject</field>
+ <field name="model_id" ref="base.model_res_users"/>
+ <field name="subject">Email Pendaftaran Bisnis Tidak Berhasil</field>
+ <field name="email_from">"Indoteknik.com" &lt;noreply@indoteknik.com&gt;</field>
+ <field name="reply_to">noreply@indoteknik.com</field>
+ <field name="email_to">${object.login | safe}</field>
+ <field name="body_html" type="html">
+ <table border="0" cellpadding="0" cellspacing="0" style="padding-top: 16px; background-color: #F1F1F1; font-family:Inter, Helvetica, Verdana, Arial,sans-serif; line-height: 24px; color: #454748; width: 100%; border-collapse:separate;">
+ <tr><td align="center">
+ <table border="0" cellpadding="0" cellspacing="0" width="590" style="font-size: 13px; padding: 16px; background-color: white; color: #454748; border-collapse:separate;">
+ <!-- HEADER -->
+ <tbody>
+ <tr>
+ <td align="center" style="min-width: 590px;">
+ <table border="0" cellpadding="0" cellspacing="0" width="590" style="min-width: 590px; background-color: white; padding: 0px 8px 0px 8px; border-collapse:separate;">
+ <tr>
+ <td valign="middle">
+ <span></span>
+ </td>
+ </tr>
+
+ <tr>
+ <td colspan="2" style="text-align:center;">
+ <hr width="100%" style="background-color:rgb(204,204,204);border:medium none;clear:both;display:block;font-size:0px;min-height:1px;line-height:0; margin: 16px 0px 16px 0px;" />
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <!-- CONTENT -->
+ <tr>
+ <td align="center" style="min-width: 590px;">
+ <table border="0" cellpadding="0" cellspacing="0" width="590" style="min-width: 590px; background-color: white; padding: 0px 8px 0px 8px; border-collapse:separate;">
+ <tr><td style="padding-bottom: 24px;"><b>Yth. ${object.user_company_name},</b></td></tr>
+
+ <tr><td style="padding-bottom: 16px;">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.</td></tr>
+ <tr><td style="padding-bottom: 16px;">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:</td></tr>
+ <tr>
+ <td style="padding-bottom: 8px; ">Informasi yang kami butuhkan saat ini adalah:</td>
+ </tr>
+ <tr>
+ <td style="padding: 4px 0; text-align: left;">
+ <ol style="padding-left: 20px; margin: 0;">
+ <li style="padding-bottom: 4px;">Detail Nama Bisnis</li>
+ <li style="padding-bottom: 4px;">Dokumen NPWP</li>
+ <li style="padding-bottom: 4px;">Dokumen SPPKP/Surat Pengukuhan Kena Pajak</li>
+ </ol>
+ </td>
+ </tr>
+
+ <tr><td style="padding-bottom: 16px;">Anda dapat mengirimkan informasi yang kurang tersebut melalui email ini atau dengan menghubungi tim layanan pelanggan kami di <a href="https://wa.me/6281717181922">0817-1718-1922</a> atau <a href="mailto:sales@indoteknik.com">sales@indoteknik.com</a>.</td></tr>
+ <tr><td style="padding-bottom: 16px;">Kami mohon maaf atas ketidaknyamanan ini dan berharap dapat segera menyelesaikan proses pendaftaran akun bisnis Anda.</td></tr>
+ <tr><td style="padding-bottom: 16px;">Terima kasih atas perhatiannya.</td></tr>
+
+ <tr><td style="padding-bottom: 2px;"><b>Hormat kami,</b></td></tr>
+ <tr><td style="padding-bottom: 2px;">Indoteknik.com</td></tr>
+ <tr>
+ <td style="text-align:center;">
+ <hr width="100%"
+ style="background-color:rgb(204,204,204);border:medium none;clear:both;display:block;font-size:0px;min-height:1px;line-height:0; margin: 16px 0px 16px 0px;" />
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <!-- CONTENT -->
+ </tbody>
+ </table>
+ </td></tr>
+ </table>
+ </field>
+ </record>
</data>
</odoo> \ No newline at end of file