Skip to Content
Menu
This question has been flagged
2 Replies
5975 Views

I cant seems to register payment using the api, got the error "This method should only be called to process a single invoice's payment". Anyway there is only single invoice id. I set the has_invoices = true and invoices_id to a single invoice id. But seems like when i use to api to read the record, it still show as has_invoices as false and invoice_id is blank after creation.

@app.route("/create_payment")
def create_payment():
payment_date = request.args.get("payment_date")
invoice_ids = int(request.args.get("invoice_ids"))
amount = request.args.get("amount")
payment_method_id = request.args.get("payment_method_id")
communication = request.args.get("communication")
payment_id = models.execute_kw(db, uid, password, 'account.payment', 'create', [{
'payment_date': payment_date,
'has_invoices': True,
'invoice_ids': [invoice_ids],
'amount': amount,
'payment_method_id': payment_method_id,
'communication': communication,
'currency_id': 38,
'journal_id': 8,
'partner_type': 'customer',
'partner_id': 92,
'payment_type': 'inbound'
}]) models.execute_kw(db, uid, password, 'account.payment', 'action_validate_invoice_payment', [payment_id]) return jsonify(payment_id)
Avatar
Discard
Author Best Answer

 'invoice_ids': [invoice_ids] suppose to be 'invoice_ids': [4,invoice_ids] then it works.

Avatar
Discard
Author

@app.route("/create_payment")

def create_payment():

payment_date = request.args.get("payment_date")

invoice_ids = int(request.args.get("invoice_ids"))

amount = request.args.get("amount")

journal_id = request.args.get("journal_id")

communication = request.args.get("communication")

payment_id = models.execute_kw(db, uid, password, 'account.payment', 'create', [{

'payment_date': payment_date,

'has_invoices': True,

'invoice_ids': [(4,invoice_ids)],

'amount': amount,

'payment_method_id': 1,

'communication': communication,

'currency_id': 38,

'journal_id': journal_id,

'partner_type': 'customer',

'partner_id': 92,

'payment_type': 'inbound'

}])

models.execute_kw(db, uid, password, 'account.payment', 'action_validate_invoice_payment', [payment_id])

return jsonify(payment_id)

Author

I think need to add bracket.

Best Answer

Can you once again post your code? I have the exact same problem, but it is not solved by using  'invoice_ids': [4,invoice_ids]

Avatar
Discard
Related Posts Replies Views Activity
0
Sep 24
3
0
Sep 24
348
1
Jun 24
666
1
Mar 24
930
2
Mar 24
4358