Skip to content

Commit

Permalink
[MIG] sequence_python: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaspaulb committed Nov 12, 2024
1 parent e9aeae3 commit 4ee2d79
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion sequence_python/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": "16.0.1.0.0",
"version": "17.0.1.0.0",
"license": "AGPL-3",
"category": "Generic Modules",
"depends": ["base"],
Expand Down
2 changes: 1 addition & 1 deletion sequence_python/models/ir_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@ def get_next_char(self, number_next):
+ interpolated_suffix
)
else:
return super(IrSequence, self).get_next_char(number_next)
return super().get_next_char(number_next)
14 changes: 14 additions & 0 deletions sequence_python/tests/test_ir_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,15 @@ def setUpClass(cls):
}
)

def test_non_python_sequence(self):
"""Verify if non-Python sequences still work"""
self.sequence.number_next_actual = 1
self.sequence.use_python_code = False
next_number = self.sequence._next()
self.assertEqual(next_number, "A01")

def test_standard_sequence(self):
self.sequence.number_next_actual = 1
self.assertEqual(self.sequence.python_code_preview, "AB01C")
next_number = self.sequence._next()
self.assertEqual(next_number, "AB01C")
Expand All @@ -37,3 +45,9 @@ def test_nogap_sequence(self):
self.assertEqual(next_number, "AB01C")
next_number = self.sequence._next()
self.assertEqual(next_number, "AB02C")

def test_preview_with_wrong_python_syntax(self):
# This will raise a Python TypeError exception
self.sequence.python_code = "number_padded + 1"
# It will not raise but put the Exception text in the preview field
self.assertIn("TypeError", self.sequence.python_code_preview)
4 changes: 2 additions & 2 deletions sequence_python/views/ir_sequence.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
widget="ace"
options="{'mode': 'python'}"
placeholder="number"
attrs="{'invisible': [('use_python_code', '=', False)]}"
invisible="use_python_code == False"
/>
<field
name="python_code_preview"
attrs="{'invisible': [('use_python_code', '=', False)]}"
invisible="use_python_code == False"
/>
</group>
<div style="margin-top: 4px;">
Expand Down

0 comments on commit 4ee2d79

Please sign in to comment.