Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
4431 Vistas
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
Descartar
Mejor respuesta

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
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
2
jun 16
15996
3
mar 15
4633
3
nov 24
3253
3
dic 22
6107
1
ene 25
8928