From cc9c34431ec16a493808a307405b772d83f4edc8 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 17 Nov 2023 09:11:39 +0700 Subject: Add voucher on activation mail feature --- indoteknik_custom/models/res_users.py | 7 +++++++ indoteknik_custom/models/voucher.py | 3 +++ indoteknik_custom/views/res_users.xml | 3 ++- indoteknik_custom/views/voucher.xml | 1 + 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/indoteknik_custom/models/res_users.py b/indoteknik_custom/models/res_users.py index 1e729550..09321fc6 100755 --- a/indoteknik_custom/models/res_users.py +++ b/indoteknik_custom/models/res_users.py @@ -32,3 +32,10 @@ class ResUsers(models.Model): 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}' + + def get_voucher_code(self, type): + if type == 'activation': + vouchers = self.env['voucher'].get_active_voucher([('show_on_email', '=', 'user_activation')]) + if not vouchers: return None + return ', '.join(x.code for x in vouchers) + return None diff --git a/indoteknik_custom/models/voucher.py b/indoteknik_custom/models/voucher.py index 2eedc861..588e9ac5 100644 --- a/indoteknik_custom/models/voucher.py +++ b/indoteknik_custom/models/voucher.py @@ -55,6 +55,9 @@ class Voucher(models.Model): ('brand', "Selected product brand"), ]) count_order = fields.Integer(string='Count Order', compute='_compute_count_order') + show_on_email = fields.Selection([ + ('user_activation', 'User Activation') + ], 'Show on Email') @api.constrains('description') def _check_description_length(self): diff --git a/indoteknik_custom/views/res_users.xml b/indoteknik_custom/views/res_users.xml index fd2d47c8..976f46c9 100644 --- a/indoteknik_custom/views/res_users.xml +++ b/indoteknik_custom/views/res_users.xml @@ -38,7 +38,8 @@ Kami senang Anda bergabung dengan Indoteknik. Untuk mengaktifkan akun anda salin kode OTP berikut ${object.otp_code}, lalu masukan pada kolom yang disediakan pada website Indoteknik.com Atau anda dapat klik tautan berikut: Aktivasi akun - Jika anda mengalami kesulitan atau memiliki pertanyaan, hubungi tim dukungan kami melalui email berikut + Jika anda mengalami kesulitan atau memiliki pertanyaan, hubungi tim dukungan kami melalui email sales@indoteknik.com + Gunakan kode voucher berikut untuk mendapatkan diskon belanja hingga 10 juta: ${object.get_voucher_code('activation')} Hormat kami, PT. Indoteknik Dotcom Gemilang diff --git a/indoteknik_custom/views/voucher.xml b/indoteknik_custom/views/voucher.xml index b8489942..71c0df0b 100755 --- a/indoteknik_custom/views/voucher.xml +++ b/indoteknik_custom/views/voucher.xml @@ -35,6 +35,7 @@ + -- cgit v1.2.3