Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie

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?


Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
0
paź 23
1626
1
lip 22
2573
1
lut 22
2790
2
sie 24
1751
1
kwi 20
3840