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 /indoteknik_custom/models | |
| parent | cb2d8e24bf7d45cf07e7c55e5476c5fd08df3a9f (diff) | |
Add voucher on activation mail feature
Diffstat (limited to 'indoteknik_custom/models')
| -rwxr-xr-x | indoteknik_custom/models/res_users.py | 7 | ||||
| -rw-r--r-- | indoteknik_custom/models/voucher.py | 3 |
2 files changed, 10 insertions, 0 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): |
