SOURCE CODE
from odoo import models, fields, api
import random
class GenerateCode(models.Model):
_name = 'generate.code'
_description = 'Generate Code'
code = fields.Text('Code')
def get_code(self):
num = "0123456789"
lowercase = "abcdefghijklmnopqrstuvwxyz"
capital = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
symbol = "!@#$%^&*()_+=-,./<>?"
n = 20
comb = num + lowercase + capital + symbol
codes = "".join(random.sample(comb,n))
self.code = codes
OUTPUT
Video