Monday, November 2, 2020

random function in odoo 14

in this blog we will explain example to generate random number of 4 digits in odoo so let us start 

 

- First we have to import choice class from random package as bellow

from random import choice

- Then we have to import digits class from string package as bellow 

from string import digits

- Last we can use the function bellow that will return the random number

def _default_random_pin(self):
        return ("".join(choice(digits) for i in range(4)))

 

No comments:

Post a Comment

Odoo Invoice Qr code issues

There are two main issues must of us facing with the QR code in Odoo invoice & these issues are 1/ QR code displayed as broken image w...