← Back to team overview

openerp-community-reviewer team mailing list archive

[Merge] lp:~camptocamp/account-financial-tools/7.0-fix-post-deleted-move-lep into lp:account-financial-tools

 

Leonardo Pistone - camptocamp has proposed merging lp:~camptocamp/account-financial-tools/7.0-fix-post-deleted-move-lep into lp:account-financial-tools.

Requested reviews:
  Account Core Editors (account-core-editors)
Related bugs:
  Bug #1285145 in Account - Financial Tools: "account_move_batch_validate: delete move before job is executed: "Field journal_id not found""
  https://bugs.launchpad.net/account-financial-tools/+bug/1285145

For more details, see:
https://code.launchpad.net/~camptocamp/account-financial-tools/7.0-fix-post-deleted-move-lep/+merge/208360
-- 
https://code.launchpad.net/~camptocamp/account-financial-tools/7.0-fix-post-deleted-move-lep/+merge/208360
Your team OpenERP Community Reviewer/Maintainer is subscribed to branch lp:account-financial-tools.
=== modified file 'account_move_batch_validate/__openerp__.py'
--- account_move_batch_validate/__openerp__.py	2014-01-17 14:24:31 +0000
+++ account_move_batch_validate/__openerp__.py	2014-02-26 13:15:26 +0000
@@ -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': [],

=== modified file 'account_move_batch_validate/account.py'
--- account_move_batch_validate/account.py	2014-02-21 13:44:05 +0000
+++ account_move_batch_validate/account.py	2014-02-26 13:15:26 +0000
@@ -127,8 +127,12 @@
 @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')

=== added file 'account_move_batch_validate/test/batch_validate_then_delete_move.yml'
--- account_move_batch_validate/test/batch_validate_then_delete_move.yml	1970-01-01 00:00:00 +0000
+++ account_move_batch_validate/test/batch_validate_then_delete_move.yml	2014-02-26 13:15:26 +0000
@@ -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'


Follow ups