mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
[fix] when a the move we want to validate is not there anymore, close the job silently, with an appropriate message. I provide a test for that.
This commit is contained in:
@@ -73,6 +73,7 @@
|
||||
'test': [
|
||||
'test/batch_validate.yml',
|
||||
'test/batch_validate_then_unmark.yml',
|
||||
'test/batch_validate_then_delete_move.yml',
|
||||
],
|
||||
'installable': True,
|
||||
'images': [],
|
||||
|
||||
@@ -127,8 +127,12 @@ class account_move(orm.Model):
|
||||
@job
|
||||
def validate_one_move(session, model_name, move_id):
|
||||
"""Validate a move, and leave the job reference in place."""
|
||||
session.pool['account.move'].button_validate(
|
||||
session.cr,
|
||||
session.uid,
|
||||
[move_id]
|
||||
)
|
||||
move_pool = session.pool['account.move']
|
||||
if move_pool.exists(session.cr, session.uid, [move_id]):
|
||||
move_pool.button_validate(
|
||||
session.cr,
|
||||
session.uid,
|
||||
[move_id]
|
||||
)
|
||||
else:
|
||||
return _(u'Nothing to do because the record has been deleted')
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
-
|
||||
I create a move
|
||||
-
|
||||
!record {model: account.move, id: move3}:
|
||||
journal_id: account.sales_journal
|
||||
line_id:
|
||||
- name: Receivable line
|
||||
account_id: account.a_recv
|
||||
debit: 3000.0
|
||||
- name: Sales line
|
||||
account_id: account.a_sale
|
||||
credit: 3000.0
|
||||
-
|
||||
I check that the move is still draft
|
||||
-
|
||||
!assert {model: account.move, id: move3}:
|
||||
- state == 'draft'
|
||||
-
|
||||
I create a wizard with a long ETA
|
||||
-
|
||||
!record {model: account.move.marker, id: wiz_marker4}:
|
||||
action: mark
|
||||
eta: 10000
|
||||
-
|
||||
I run the wizard
|
||||
-
|
||||
!python {model: account.move.marker}: |
|
||||
self.button_mark(
|
||||
cr, uid, [ref('wiz_marker4')], context=context
|
||||
)
|
||||
-
|
||||
I read the UUID from the move, delete the move, then dequeue the job and run it.
|
||||
It should raise no exceptions.
|
||||
-
|
||||
!python {model: account.move}: |
|
||||
from openerp.addons.connector.queue.job import OpenERPJobStorage
|
||||
from openerp.addons.connector.session import ConnectorSession
|
||||
|
||||
move = self.browse(cr, uid, ref('move3'), context=context)
|
||||
uuid = move.post_job_uuid
|
||||
|
||||
assert uuid, 'The Job has not been created.'
|
||||
self.unlink(cr, uid, ref('move3'), context=context)
|
||||
|
||||
session = ConnectorSession(cr, uid, context=context)
|
||||
storage = OpenERPJobStorage(session)
|
||||
|
||||
myjob = storage.load(uuid)
|
||||
myjob.perform(session)
|
||||
|
||||
assert myjob.result == u'Nothing to do because the record has been deleted'
|
||||
Reference in New Issue
Block a user