Skip to Content
Menu
This question has been flagged
1 Reply
3510 Views
Hello,

I'm trying to multiplicate/duplicate invoices because I want to stress-test it paying simultaneously a lot of them. I can duplicate an invoice from inside the actual invoice, but since I want to have 100-200s, there must be a more efficient way than duplicating them one by one. Is there a way to do so by code?
I've tried using
invoices = call('account.invoice','search_read', [('type','ilike',"out_invoice")])
for invoice in invoices:
    call('account.invoice', 'create', invoice)
But I'm getting this error

Traceback (most recent call last):  File "/home/carlos/Odoo/odoo/custom-addons/tests/test-seq-create-course-sessions/test.py", line 30, in <module> [ ... ]  File "/usr/lib/python2.7/xmlrpclib.py", line 794, in close    raise Fault(**self._stack[0])xmlrpclib.Fault: <Fault invalid input syntax for integer: "Sales Journal - (test) (EUR)"LINE 1: ...11', '0.00', NULL, NULL, 'SAJ/2016/008', ARRAY[1, 'Sales Jou...                                                                                                                                       ^

I'm assuming the error is that I'm duplicating an invoice with a previously used id (SAJ/2016/008) . I've tried changing the id but I'm still getting the exact same mistake.
invoices = call('account.invoice','search_read', [('type','ilike',"out_invoice")])
for invoice in invoices:
  replace='SAJ/2016/010' # new Id
  invoice['internal_number']=replace
  invoice['number']=replace
  call('account.invoice', 'create', invoice) 
 Any ideas on how to multiply/duplicate invoices?

Thank you
Avatar
Discard
Best Answer

Try use the erppeek library



import erppeek
import functools
SERVER = 'http://localhost:8069'
DATABASE = 'DB'
USERNAME = 'admin'
PASSWORD = 'admin'
client = erppeek.Client(SERVER, DATABASE, USERNAME, PASSWORD)
invoices=client.search('account.invoice',[('type','ilike',"out_invoice")])
for i in range(len(invoices)):
 client.copy('account.invoice',invoices[i])


Avatar
Discard
Related Posts Replies Views Activity
2
Jun 16
14503
3
Mar 15
3398
3
Nov 24
1363
3
Dec 22
4868
1
Nov 24
7831