问题
First I created the function:
def invoiceRegisterPayment(self,register_payment_row):
confirm_result = self.ODOO_OBJECT.execute_kw(
self.DATA,
self.UID,
self.PASS,
'account.payment',
'action_validate_invoice_payment',
register_payment_row)
return confirm_result
Then I passed the following parameters:
register_payment_row = [
[payment_id],
{
"active_id":invoice_id,
"active_ids":[invoice_id],
"active_model": "account.invoice",
"default_invoice_ids":[[4,invoice_id,None]],
"journal_type":"sale",
"lang":"en_US",
"search_disable_custom_filters": True,
"type": "out_invoice",
"tz": False,
"uid": 2
} ]
But it shows the following error: "This method should only be called to process a single invoice's payment."
This is the print of register_payment_row:
[[67], {'active_id': 119, 'active_ids': [119], 'active_model': 'account.invoice', 'default_invoice_ids': [4, 119, None], 'journal_type': 'sale', 'lang': 'en_US', 'search_disable_custom_filters': True, 'type': 'out_invoice', 'tz': False, 'uid': 2}]
回答1:
Please try the following data structure and pass to create method account.payment model.
{ invoice_ids: [ [ 4, "Invoice Id", 'None' ] ],
default_invoice_ids: [ [ 4, "Invoice Id", 'None' ] ],
amount: 'Amount',
payment_date: '2019-05-21 02:55:52',
payment_type: 'inbound',
has_invoices: true,
currency_id: 1,
journal_id: 6,
payment_method_id: 1,
partner_id: 226,
partner_type: 'customer',
communication: 'INV/2019/0141/44',
name: 'INV/2019/0141/44' }
来源:https://stackoverflow.com/questions/53579842/how-to-register-payment-using-python-xml-rpc-in-odoo-12