This commit is contained in:
+4
-1
@@ -308,7 +308,10 @@ class NCFManagerSequences(Workflow, ModelSQL, ModelView):
|
||||
|
||||
ncf_sequences = fields.Many2One('ir.sequence.strict', 'Fiscal Sequence',
|
||||
domain=[
|
||||
['OR',
|
||||
('company', '=', Eval('company', -1)),
|
||||
('company', '=', None),
|
||||
],
|
||||
If(Eval('state') == 'draft',
|
||||
('prefix', '=', Eval('expected_prefix')),
|
||||
()),
|
||||
@@ -499,7 +502,7 @@ class NCFManagerSequences(Workflow, ModelSQL, ModelView):
|
||||
if self.ncf_type == '99':
|
||||
raise UserError(gettext(
|
||||
'ncf_manager.msg_ncf_non_fiscal_sequence'))
|
||||
if sequence.company != self.pos.company:
|
||||
if sequence.company and sequence.company != self.pos.company:
|
||||
raise UserError(gettext(
|
||||
'ncf_manager.msg_ncf_sequence_company_mismatch'))
|
||||
expected_prefix = ncf_prefix(self.ncf_type)
|
||||
|
||||
@@ -332,6 +332,48 @@ class NcfManagerTestCase(ModuleTestCase):
|
||||
self.assertEqual(manager.ncf_sequences[0].state, 'finished')
|
||||
self.assertIsNotNone(manager.finished_at)
|
||||
|
||||
@with_transaction()
|
||||
def test_global_fiscal_sequence_can_be_assigned_to_manager(self):
|
||||
'Global fiscal sequences can be attached to a company authorization'
|
||||
pool = Pool()
|
||||
Manager = pool.get('ncf.manager')
|
||||
ManagerSequence = pool.get('ncf.manager.sequence')
|
||||
ModelData = pool.get('ir.model.data')
|
||||
StrictSequence = pool.get('ir.sequence.strict')
|
||||
SequenceType = pool.get('ir.sequence.type')
|
||||
today = datetime.date.today()
|
||||
company = self._create_company()
|
||||
|
||||
sequence_type = SequenceType(ModelData.get_id(
|
||||
'ncf_manager', 'sequence_type_out_invoice_01'))
|
||||
strict_sequence, = StrictSequence.create([{
|
||||
'name': 'Factura de Crédito Fiscal',
|
||||
'sequence_type': sequence_type.id,
|
||||
'prefix': 'B01',
|
||||
'padding': 8,
|
||||
'number_next': 1,
|
||||
'number_increment': 1,
|
||||
'from_number': 1,
|
||||
'until_number': 100,
|
||||
'expiration_date': datetime.date(today.year, 12, 31),
|
||||
}])
|
||||
manager, = Manager.create([{
|
||||
'company': company.id,
|
||||
'app_date': today,
|
||||
'app_number': 'APP0000001',
|
||||
'auth_number': 'AUT0000001',
|
||||
}])
|
||||
|
||||
line, = ManagerSequence.create([{
|
||||
'pos': manager.id,
|
||||
'invoice_type': 'invoice_customer',
|
||||
'ncf_type': '1',
|
||||
'sequence_mode': 'existing',
|
||||
'ncf_sequences': strict_sequence.id,
|
||||
}])
|
||||
|
||||
self.assertEqual(line.ncf_sequences, strict_sequence)
|
||||
|
||||
@with_transaction()
|
||||
def test_overlap_is_independent_by_invoice_direction(self):
|
||||
'A supplier range must not block the company outgoing authorization'
|
||||
|
||||
Reference in New Issue
Block a user