line: 'number' bei check->done schreiben korrigert + test
This commit is contained in:
parent
b78ff02500
commit
ba3892aa03
2 changed files with 88 additions and 1 deletions
2
line.py
2
line.py
|
@ -722,7 +722,7 @@ class Line(Workflow, ModelSQL, ModelView):
|
||||||
# deny write if line is not 'Edit'
|
# deny write if line is not 'Edit'
|
||||||
if line.state != 'edit':
|
if line.state != 'edit':
|
||||||
# allow state-update, if its the only action
|
# allow state-update, if its the only action
|
||||||
if not ((len(set({'state', 'reconciliation'}).intersection(values.keys())) > 0) \
|
if not ((len(set({'state', 'reconciliation', 'number'}).intersection(values.keys())) > 0) \
|
||||||
and (len(values.keys()) == 1)):
|
and (len(values.keys()) == 1)):
|
||||||
raise UserError(gettext(
|
raise UserError(gettext(
|
||||||
'cashbook.msg_line_deny_write',
|
'cashbook.msg_line_deny_write',
|
||||||
|
|
|
@ -366,6 +366,93 @@ class LineTestCase(ModuleTestCase):
|
||||||
self.assertEqual(book.lines[3].reconciliation, None)
|
self.assertEqual(book.lines[3].reconciliation, None)
|
||||||
self.assertEqual(book.lines[3].state, 'edit')
|
self.assertEqual(book.lines[3].state, 'edit')
|
||||||
|
|
||||||
|
@with_transaction()
|
||||||
|
def test_line_set_number_with_done(self):
|
||||||
|
""" create cashbook + line, write number to line
|
||||||
|
at state-change check->done
|
||||||
|
"""
|
||||||
|
pool = Pool()
|
||||||
|
Book = pool.get('cashbook.book')
|
||||||
|
Lines = pool.get('cashbook.line')
|
||||||
|
Reconciliation = pool.get('cashbook.recon')
|
||||||
|
|
||||||
|
types = self.prep_type()
|
||||||
|
category = self.prep_category(cattype='in')
|
||||||
|
company = self.prep_company()
|
||||||
|
party = self.prep_party()
|
||||||
|
with Transaction().set_context({
|
||||||
|
'company': company.id,
|
||||||
|
}):
|
||||||
|
book, = Book.create([{
|
||||||
|
'name': 'Book 1',
|
||||||
|
'btype': types.id,
|
||||||
|
'company': company.id,
|
||||||
|
'currency': company.currency.id,
|
||||||
|
'number_sequ': self.prep_sequence().id,
|
||||||
|
'start_date': date(2022, 5, 1),
|
||||||
|
'number_atcheck': False,
|
||||||
|
'lines': [('create', [{
|
||||||
|
'date': date(2022, 5, 1),
|
||||||
|
'description': 'Text 1',
|
||||||
|
'category': category.id,
|
||||||
|
'bookingtype': 'in',
|
||||||
|
'amount': Decimal('1.0'),
|
||||||
|
'party': party.id,
|
||||||
|
}, {
|
||||||
|
'date': date(2022, 5, 2),
|
||||||
|
'description': 'Text 2',
|
||||||
|
'category': category.id,
|
||||||
|
'bookingtype': 'in',
|
||||||
|
'amount': Decimal('1.0'),
|
||||||
|
'party': party.id,
|
||||||
|
}])],
|
||||||
|
}])
|
||||||
|
self.assertEqual(book.name, 'Book 1')
|
||||||
|
self.assertEqual(book.btype.rec_name, 'CAS - Cash')
|
||||||
|
self.assertEqual(book.state, 'open')
|
||||||
|
self.assertEqual(book.number_atcheck, False)
|
||||||
|
self.assertEqual(len(book.lines), 2)
|
||||||
|
self.assertEqual(book.lines[0].date, date(2022, 5, 1))
|
||||||
|
self.assertEqual(book.lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||||
|
self.assertEqual(book.lines[0].state_cashbook, 'open')
|
||||||
|
self.assertEqual(book.lines[1].date, date(2022, 5, 2))
|
||||||
|
self.assertEqual(book.lines[1].rec_name, '05/02/2022|Rev|1.00 usd|Text 2 [Cat1]')
|
||||||
|
|
||||||
|
# add reconciliation
|
||||||
|
Book.write(*[
|
||||||
|
[book],
|
||||||
|
{
|
||||||
|
'reconciliations': [('create', [{
|
||||||
|
'date': date(2022, 5, 1),
|
||||||
|
'date_from': date(2022, 5, 1),
|
||||||
|
'date_to': date(2022, 5, 30),
|
||||||
|
}])],
|
||||||
|
}])
|
||||||
|
self.assertEqual(len(book.reconciliations), 1)
|
||||||
|
self.assertEqual(len(book.reconciliations[0].lines), 0)
|
||||||
|
self.assertEqual(book.reconciliations[0].date_from, date(2022, 5, 1))
|
||||||
|
self.assertEqual(book.reconciliations[0].date_to, date(2022, 5, 30))
|
||||||
|
self.assertEqual(book.reconciliations[0].state, 'edit')
|
||||||
|
|
||||||
|
Lines.wfcheck(book.lines)
|
||||||
|
self.assertEqual(book.lines[0].state, 'check')
|
||||||
|
self.assertEqual(book.lines[0].number, None)
|
||||||
|
self.assertEqual(book.lines[1].state, 'check')
|
||||||
|
self.assertEqual(book.lines[1].number, None)
|
||||||
|
|
||||||
|
Reconciliation.wfcheck(book.reconciliations)
|
||||||
|
self.assertEqual(len(book.reconciliations[0].lines), 2)
|
||||||
|
self.assertEqual(book.reconciliations[0].lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||||
|
self.assertEqual(book.reconciliations[0].lines[1].rec_name, '05/02/2022|Rev|1.00 usd|Text 2 [Cat1]')
|
||||||
|
self.assertEqual(book.reconciliations[0].lines[0].number, None)
|
||||||
|
self.assertEqual(book.reconciliations[0].lines[1].number, None)
|
||||||
|
|
||||||
|
Reconciliation.wfdone(book.reconciliations)
|
||||||
|
self.assertEqual(book.reconciliations[0].lines[0].number, '1')
|
||||||
|
self.assertEqual(book.reconciliations[0].lines[0].state, 'done')
|
||||||
|
self.assertEqual(book.reconciliations[0].lines[1].number, '2')
|
||||||
|
self.assertEqual(book.reconciliations[0].lines[1].state, 'done')
|
||||||
|
|
||||||
@with_transaction()
|
@with_transaction()
|
||||||
def test_line_create_check_names_search(self):
|
def test_line_create_check_names_search(self):
|
||||||
""" create cashbook + line
|
""" create cashbook + line
|
||||||
|
|
Loading…
Reference in a new issue