Debian Codegraph @

addons/sms/wizard/sms_account_phone.py

raw symbols SCIP
1 # Part of Odoo. See LICENSE file for full copyright and licensing details.
2
3 from odoo import fields, models, _
4 from odoo.addons.sms.tools.sms_api import ERROR_MESSAGES, SmsApi
5 from odoo.exceptions import ValidationError
6
7
8 class SmsAccountPhone(models.TransientModel):
9 _name = 'sms.account.phone'
10 _description = 'SMS Account Registration Phone Number Wizard'
11
12 account_id = fields.Many2one('iap.account', required=True)
13 phone_number = fields.Char(required=True)
14
15 def action_send_verification_code(self):
16 status = SmsApi(self.env, self.account_id)._send_verification_sms(self.phone_number)['state']
17 if status != 'success':
18 raise ValidationError(ERROR_MESSAGES.get(status, ERROR_MESSAGES['unknown_error']))
19
20 return {
21 'type': 'ir.actions.act_window',
22 'target': 'new',
23 'name': _('Register Account'),
24 'view_mode': 'form',
25 'res_model': 'sms.account.code',
26 'context': {'default_account_id': self.account_id.id},
27 }