From c7595022c4c55af03d68401e58d8cd69d7ac4114 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Arturo=20Garci=CC=81a?= Date: Wed, 30 Sep 2026 22:44:31 -0400 Subject: [PATCH] Default manual fiscal sequences to current company --- ncf_manager.py | 3 +++ tests/test_module.py | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/ncf_manager.py b/ncf_manager.py index df5cefa..6dd9f9a 100644 --- a/ncf_manager.py +++ b/ncf_manager.py @@ -307,6 +307,9 @@ class NCFManagerSequences(Workflow, ModelSQL, ModelView): depends=_depends, sort=False) ncf_sequences = fields.Many2One('ir.sequence.strict', 'Fiscal Sequence', + context={ + 'company': Eval('company', -1), + }, domain=[ ['OR', ('company', '=', Eval('company', -1)), diff --git a/tests/test_module.py b/tests/test_module.py index c10b710..1d032bd 100644 --- a/tests/test_module.py +++ b/tests/test_module.py @@ -374,6 +374,17 @@ class NcfManagerTestCase(ModuleTestCase): self.assertEqual(line.ncf_sequences, strict_sequence) + @with_transaction() + def test_manual_sequence_creation_defaults_to_current_company(self): + 'Manual sequence creation uses the current company from context' + StrictSequence = Pool().get('ir.sequence.strict') + company = self._create_company() + + with Transaction().set_context(company=company.id): + defaults = StrictSequence.default_get(['company']) + + self.assertEqual(defaults['company'], company.id) + @with_transaction() def test_overlap_is_independent_by_invoice_direction(self): 'A supplier range must not block the company outgoing authorization'