Pular para o conteúdo
Menu
Esta pergunta foi sinalizada
2220 Visualizações

Hi,

I am using Python and xmlrpc to modify my database. We need to clear the payment information of all our incoming invoices. I know that by hand you can reset the invoice to draft and then post it again which removes the payment information. However when i do this via code, the payment stays. I tried two approaches:


Method 1 - reset the invoices to draft and back to posted state:

query = [[["state", "=", "posted"], ["type", "=", "in_invoice"], ["invoice_payment_state", "=", "paid"]]]
data = models.execute_kw(db, uid, password, "account.move", "search", query)

for i in range(len(data)):

    ret = models.execute_kw(db, uid, password, "account.move", "write",[[data[i]], {"invoice_payment_state": "not_paid", "invoice_payments_widget": "false", "has_reconciled_entries": False}])


Method 2 - change fields invoice_payment_state, invoice_payments_widgets and has_reconciled_entries (only posting the execute_kw statement):

     ret = models.execute_kw(db, uid, password, "account.move", "write", [[data[i]], {"invoice_payment_state": "not_paid", "invoice_payments_widget": "false", "has_reconciled_entries": False}])


I am really uncomfortable with method 2, as other fields might be affected by the payment-flag which i am not aware off. Whats the best option for this? Or is there something i can do with a built in feature?


Avatar
Cancelar
Publicações relacionadas Respostas Visualizações Atividade
0
out. 23
1721
1
jul. 22
2649
1
fev. 22
2869
2
ago. 24
1869
1
abr. 20
3890