[FIX] base: ir sequence number is now reset to the requested value when calling the write method
opw: 626974
This commit is contained in:
parent
edcbf067d6
commit
2275af4b77
|
@ -198,7 +198,7 @@ class ir_sequence(openerp.osv.osv.osv):
|
||||||
if new_implementation in ('standard', None):
|
if new_implementation in ('standard', None):
|
||||||
# Implementation has NOT changed.
|
# Implementation has NOT changed.
|
||||||
# Only change sequence if really requested.
|
# Only change sequence if really requested.
|
||||||
if row['number_next'] != n:
|
if values.get('number_next'):
|
||||||
self._alter_sequence(cr, row['id'], i, n)
|
self._alter_sequence(cr, row['id'], i, n)
|
||||||
else:
|
else:
|
||||||
# Just in case only increment changed
|
# Just in case only increment changed
|
||||||
|
|
|
@ -6,6 +6,7 @@ import test_ir_values
|
||||||
import test_menu
|
import test_menu
|
||||||
import test_search
|
import test_search
|
||||||
import test_views
|
import test_views
|
||||||
|
import test_ir_sequence
|
||||||
|
|
||||||
checks = [
|
checks = [
|
||||||
test_base,
|
test_base,
|
||||||
|
@ -16,4 +17,5 @@ checks = [
|
||||||
test_menu,
|
test_menu,
|
||||||
test_search,
|
test_search,
|
||||||
test_views,
|
test_views,
|
||||||
|
test_ir_sequence,
|
||||||
]
|
]
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
import unittest2
|
||||||
|
|
||||||
|
import openerp.tests.common as common
|
||||||
|
|
||||||
|
|
||||||
|
class Test_ir_sequence(common.TransactionCase):
|
||||||
|
|
||||||
|
def test_00(self):
|
||||||
|
registry, cr, uid = self.registry, self.cr, self.uid
|
||||||
|
|
||||||
|
# test if read statement return the good number_next value (from postgreSQL sequence and not ir_sequence value)
|
||||||
|
sequence = registry('ir.sequence')
|
||||||
|
# first creation of sequence (normal)
|
||||||
|
values = {'number_next': 1,
|
||||||
|
'company_id': 1,
|
||||||
|
'padding': 4,
|
||||||
|
'number_increment': 1,
|
||||||
|
'implementation': 'standard',
|
||||||
|
'name': 'test-sequence-00'}
|
||||||
|
seq_id = sequence.create(cr, uid, values)
|
||||||
|
# Call get next 4 times
|
||||||
|
sequence.next_by_id(cr, uid, seq_id)
|
||||||
|
sequence.next_by_id(cr, uid, seq_id)
|
||||||
|
sequence.next_by_id(cr, uid, seq_id)
|
||||||
|
read_sequence = sequence.next_by_id(cr, uid, seq_id)
|
||||||
|
# Read the value of the current sequence
|
||||||
|
assert read_sequence == "0004", 'The actual sequence value must be 4. reading : %s' % read_sequence
|
||||||
|
# reset sequence to 1 by write method calling
|
||||||
|
sequence.write(cr, uid, [seq_id], {'number_next': 1})
|
||||||
|
# Read the value of the current sequence
|
||||||
|
read_sequence = sequence.next_by_id(cr, uid, seq_id)
|
||||||
|
assert read_sequence == "0001", 'The actual sequence value must be 1. reading : %s' % read_sequence
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest2.main()
|
Loading…
Reference in New Issue