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'