[MIG] sequence_python: Migration to 14.0
parent
42bffb3e53
commit
7097f6a012
|
@ -5,7 +5,7 @@
|
|||
"summary": """Calculate a sequence number from a Python expression""",
|
||||
"author": "Sunflower IT,Odoo Community Association (OCA)",
|
||||
"website": "https://github.com/OCA/server-tools",
|
||||
"version": "13.0.1.0.0",
|
||||
"version": "14.0.1.0.0",
|
||||
"license": "AGPL-3",
|
||||
"category": "Generic Modules",
|
||||
"depends": ["base"],
|
||||
|
|
|
@ -4,9 +4,10 @@ import logging
|
|||
import random
|
||||
import string
|
||||
import uuid
|
||||
from inspect import getmembers, isclass, isfunction
|
||||
|
||||
from odoo import fields, models
|
||||
from odoo.tools import safe_eval
|
||||
from odoo.tools.safe_eval import safe_eval, wrap_module
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -40,13 +41,19 @@ class IrSequence(models.Model):
|
|||
You can inherit this in your custom module.
|
||||
:return: tuple
|
||||
"""
|
||||
wrap_random = wrap_module(random, random.__all__)
|
||||
uuid_elements = [e[0] for e in getmembers(uuid, isfunction)] + [
|
||||
e[0] for e in getmembers(uuid, isclass)
|
||||
]
|
||||
wrap_uuid = wrap_module(uuid, uuid_elements)
|
||||
wrap_string = wrap_module(string, string.__all__)
|
||||
return {
|
||||
"number": number_next[0] if isinstance(number_next, tuple) else number_next,
|
||||
"number_padded": "%%0%sd" % self.padding % number_next,
|
||||
"sequence": self,
|
||||
"random": random,
|
||||
"uuid": uuid,
|
||||
"string": string,
|
||||
"random": wrap_random,
|
||||
"uuid": wrap_uuid,
|
||||
"string": wrap_string,
|
||||
}
|
||||
|
||||
def _get_python_value(self, number_next):
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
* Tom Blauwendraat <tom@sunflowerweb.nl>
|
||||
* Francesco Apruzzese <cescoap@gmail.com>
|
||||
|
|
|
@ -25,15 +25,16 @@ class TestIrSequence(SavepointCase):
|
|||
)
|
||||
|
||||
def test_standard_sequence(self):
|
||||
self.assertEquals(self.sequence.python_code_preview, "AB01C")
|
||||
# import pdb;pdb.set_trace()
|
||||
self.assertEqual(self.sequence.python_code_preview, "AB01C")
|
||||
next_number = self.sequence._next()
|
||||
self.assertEquals(next_number, "AB01C")
|
||||
self.assertEqual(next_number, "AB01C")
|
||||
next_number = self.sequence._next()
|
||||
self.assertEquals(next_number, "AB02C")
|
||||
self.assertEqual(next_number, "AB02C")
|
||||
|
||||
def test_nogap_sequence(self):
|
||||
self.sequence.write(dict(implementation="no_gap"))
|
||||
next_number = self.sequence._next()
|
||||
self.assertEquals(next_number, "AB01C")
|
||||
self.assertEqual(next_number, "AB01C")
|
||||
next_number = self.sequence._next()
|
||||
self.assertEquals(next_number, "AB02C")
|
||||
self.assertEqual(next_number, "AB02C")
|
||||
|
|
Loading…
Reference in New Issue