From 4ee2d79cdcf8377d814407d365732344cbe9a95a Mon Sep 17 00:00:00 2001 From: Tom Date: Tue, 12 Nov 2024 14:39:02 +0100 Subject: [PATCH] [MIG] sequence_python: Migration to 17.0 --- sequence_python/__manifest__.py | 2 +- sequence_python/models/ir_sequence.py | 2 +- sequence_python/tests/test_ir_sequence.py | 14 ++++++++++++++ sequence_python/views/ir_sequence.xml | 4 ++-- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/sequence_python/__manifest__.py b/sequence_python/__manifest__.py index 088f1338a19..0eb9eafe9bf 100644 --- a/sequence_python/__manifest__.py +++ b/sequence_python/__manifest__.py @@ -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"], diff --git a/sequence_python/models/ir_sequence.py b/sequence_python/models/ir_sequence.py index 4da75f9fc38..2e60b5cae89 100644 --- a/sequence_python/models/ir_sequence.py +++ b/sequence_python/models/ir_sequence.py @@ -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) diff --git a/sequence_python/tests/test_ir_sequence.py b/sequence_python/tests/test_ir_sequence.py index c4f684177f8..8868b3a89b2 100644 --- a/sequence_python/tests/test_ir_sequence.py +++ b/sequence_python/tests/test_ir_sequence.py @@ -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") @@ -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) diff --git a/sequence_python/views/ir_sequence.xml b/sequence_python/views/ir_sequence.xml index 743a628b8e0..dd2882764ca 100644 --- a/sequence_python/views/ir_sequence.xml +++ b/sequence_python/views/ir_sequence.xml @@ -13,11 +13,11 @@ widget="ace" options="{'mode': 'python'}" placeholder="number" - attrs="{'invisible': [('use_python_code', '=', False)]}" + invisible="use_python_code == False" />