[FIX] coupon: fix undeterministic error in test
The previous code generation for coupon used `getrandbits` which provides a less randomised code than uuid4 causing undeterministic errors during the tests. TaskId-2786904 closes odoo/odoo#87299 X-original-commit: 7c2d68b466e13a25a6dd7091383b1f9810f1a630 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com> Signed-off-by: William Braeckman (wbr) <wbr@odoo.com>
This commit is contained in:
@@ -5,6 +5,7 @@ from dateutil.relativedelta import relativedelta
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
|
||||
from uuid import uuid4
|
||||
|
||||
class Coupon(models.Model):
|
||||
_name = 'coupon.coupon'
|
||||
@@ -22,7 +23,7 @@ class Coupon(models.Model):
|
||||
Generate 8 bytes (64 bits) barcodes as 16 bytes barcodes are not
|
||||
compatible with all scanners.
|
||||
"""
|
||||
return str(random.getrandbits(64))
|
||||
return str(uuid4())[:22]
|
||||
|
||||
code = fields.Char(default=lambda self: self._generate_code(), required=True, readonly=True)
|
||||
expiration_date = fields.Date('Expiration Date', compute='_compute_expiration_date')
|
||||
|
||||
Reference in New Issue
Block a user