diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2023-11-17 09:11:39 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2023-11-17 09:11:39 +0700 |
| commit | cc9c34431ec16a493808a307405b772d83f4edc8 (patch) | |
| tree | 5d08e5193e3e8bf098d6e391e85e5d190f60c176 | |
| parent | cb2d8e24bf7d45cf07e7c55e5476c5fd08df3a9f (diff) | |
Add voucher on activation mail feature
| -rwxr-xr-x | indoteknik_custom/models/res_users.py | 7 | ||||
| -rw-r--r-- | indoteknik_custom/models/voucher.py | 3 | ||||
| -rw-r--r-- | indoteknik_custom/views/res_users.xml | 3 | ||||
| -rwxr-xr-x | indoteknik_custom/views/voucher.xml | 1 |
4 files changed, 13 insertions, 1 deletions
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 @@ <tr><td style="padding-bottom: 16px;">Kami senang Anda bergabung dengan Indoteknik.</td></tr> <tr><td style="padding-bottom: 16px;">Untuk mengaktifkan akun anda salin kode OTP berikut <strong>${object.otp_code}</strong>, lalu masukan pada kolom yang disediakan pada website Indoteknik.com</td></tr> <tr><td style="padding-bottom: 16px;">Atau anda dapat klik tautan berikut: <a href="${object.get_activation_token_url() | safe}">Aktivasi akun</a></td></tr> - <tr><td style="padding-bottom: 16px;">Jika anda mengalami kesulitan atau memiliki pertanyaan, hubungi tim dukungan kami melalui email <a href="mailto:sales@indoteknik.com">berikut</a></td></tr> + <tr><td style="padding-bottom: 16px;">Jika anda mengalami kesulitan atau memiliki pertanyaan, hubungi tim dukungan kami melalui email <a href="mailto:sales@indoteknik.com">sales@indoteknik.com</a></td></tr> + <tr><td style="padding-bottom: 16px;">Gunakan kode voucher berikut untuk mendapatkan diskon belanja hingga 10 juta: <strong>${object.get_voucher_code('activation')}</strong></td></tr> <tr><td style="padding-bottom: 2px;">Hormat kami,</td></tr> <tr><td style="padding-bottom: 2px;">PT. Indoteknik Dotcom Gemilang</td></tr> 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 @@ <field name="limit" required="1"/> <field name="limit_user" required="1"/> <field name="apply_type" required="1" /> + <field name="show_on_email" /> <field name="excl_pricelist_ids" widget="many2many_tags" domain="[('id', 'in', [4, 15037, 15038, 15039, 17023, 17024, 17025, 17026,17027])]"/> </group> <group string="Discount Settings" attrs="{'invisible': [('apply_type', '!=', 'all')]}"> |
