← Back to team overview

credativ team mailing list archive

[Branch ~credativ/openobject-addons/6.1] Rev 7073: [IMP] Efficiency improved by validating journal entry once

 

------------------------------------------------------------
revno: 7073
committer: Jacob Hicks <jacob.hicks@xxxxxxxxxxxxxx>
branch nick: addons
timestamp: Mon 2015-07-13 13:22:45 +0100
message:
  [IMP] Efficiency improved by validating journal entry once
modified:
  account/account_invoice.py
  account/account_move_line.py


--
lp:~credativ/openobject-addons/6.1
https://code.launchpad.net/~credativ/openobject-addons/6.1

Your team credativ is subscribed to branch lp:~credativ/openobject-addons/6.1.
To unsubscribe from this branch go to https://code.launchpad.net/~credativ/openobject-addons/6.1/+edit-subscription
=== modified file 'account/account_invoice.py'
--- account/account_invoice.py	2015-04-21 13:15:51 +0000
+++ account/account_invoice.py	2015-07-13 12:22:45 +0000
@@ -951,7 +951,11 @@
                 for i in line:
                     i[2]['period_id'] = period_id
 
+            # Call create method without validation, and then validate once for whole move
+            ctx.update({'novalidate': True})
             move_id = move_obj.create(cr, uid, move, context=ctx)
+            move_obj.button_validate(cr,uid, [move_id], context=ctx)
+            
             new_move_name = move_obj.browse(cr, uid, move_id, context=ctx).name
             # make the invoice point to that move
             self.write(cr, uid, [inv.id], {'move_id': move_id,'period_id':period_id, 'move_name':new_move_name}, context=ctx)

=== modified file 'account/account_move_line.py'
--- account/account_move_line.py	2013-06-19 12:57:27 +0000
+++ account/account_move_line.py	2015-07-13 12:22:45 +0000
@@ -1392,7 +1392,8 @@
                     self.create(cr, uid, data, context)
             del vals['account_tax_id']
 
-        if check and ((not context.get('no_store_function')) or journal.entry_posted):
+        # Allow preventing validation by passing novalidate through context
+        if check and not context.get('novalidate') and ((not context.get('no_store_function')) or journal.entry_posted):
             tmp = move_obj.validate(cr, uid, [vals['move_id']], context)
             if journal.entry_posted and tmp:
                 move_obj.button_validate(cr,uid, [vals['move_id']], context)