Guest User

Untitled

a guest
Jul 18th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. # Put your model and field name here.
  2. model_name = 'account.invoice'
  3. field_name = 'residual'
  4.  
  5. # Do not change anything below this line.
  6.  
  7. model = env[model_name]
  8. offset = 0
  9. page_size = 100
  10. set = model.search([], limit=page_size, offset=offset, order='id asc')
  11. count = model.search_count([])
  12. while len(set):
  13. print('Processed: %i/%i' % (offset, count))
  14. env.add_todo(model._fields[field_name], set)
  15. model.recompute()
  16. # Clear the cache to avoid hitting memory limit.
  17. env.clear()
  18. offset += page_size
  19. env.cr.commit()
  20. set = model.search([], limit=page_size, offset=offset, order='id asc')
  21.  
  22. print('Done')
Add Comment
Please, Sign In to add comment