I am using ODOO12. How to validate a reference number against generated referene number and if valid then on submit button click it will send an OTP.
This question has been flagged
Thanks Niyas for your answer. I want to write this validation in api, so can you please send me some reference or a example?, so that i can get more clarity. I am mentioning the code below that I have generate random reference number. Now I want to write code for verify this created reference number ,If it is valid then it will get the mobile number and send OTP to this number.
My requirement is I have created a random reference number generate by this coding ---
@api.model
def create(self, vals):
vals['reference_no']= ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(10))
' new_record = super().create(vals)
return new_record
Hi,
This is the simple case where you can convert your logic into the code. You should have stored the generated reference somewhere in the system(either in some records), then once the end user enters the reference number somewhere, in button action you can check whether the entered and stored are same or not using a IF condition. If same you can send OTP via email or SMS to the phone number or to the email.
For sending email: https://www.odoo.yenthevg.com/sending-mail-templates-odoo/
Thanks
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up