How to register payment using Python XML-RPC in Odoo 12

雨燕双飞 提交于 2019-12-10 22:06:01

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!