Odoo 14 - account. payment 发票_ids 已删除,但它被替换为什么?

问题描述 投票:0回答:2

直到 Odoo 12,在使用发票 API 调用创建付款时,我们必须填充 account. payment 模块上的发票_ids 字段,一旦付款验证,它将自动标记相应的发票已付款。

我知道没有功能损失,但是,我不知道这个功能被什么取代了。

我尝试使用invoice_line_ids,发票仍然没有被标记为PAID。只有 1 move_id,即使我尝试发票仍然没有被标记为已付款。

有什么想法吗?

编辑:这是我尝试发送到 Odoo 以根据发票注册付款的 json。但回应是: “注册付款向导只能在 account.move 或 account.move.line 记录上调用。” 我在 json 中传递参数后创建了一个单独的内容,但响应仍然保持不变。

{
  "jsonrpc":"2.0",
  "method":"call",
  "params":{
    "service": "object",
    "method": "execute",
    "args":[
        "{{databaseName}}",
        {{userId}},
        "{{password}}",
        "account.payment.register",
        "create",
     {
        "can_edit_wizard":true,
        "can_group_payments":false,
        "payment_type":"inbound",
        "partner_type":"customer",
        "source_amount":5.48,
        "source_amount_currency":5.48,
        "source_currency_id":2,
        "partner_id":505449,
        "country_code":"US",
        "journal_id":230,
        "other_journal_id":false,
        "show_other_journal":false,
        "payment_method_id":7,
        "partner_bank_id":false,
        "group_payment":true,
        "amount":5.48,
        "currency_id":2,
        "payment_date":"2022-02-04",
        "communication":"Test Create Invoice 32",
        "payment_difference_handling":"open",
        "writeoff_account_id":false,
        "writeoff_label":"Write-Off",
        "active_model":"account.move",
        "active_id":364660,
        "active_ids":[
           364660
        ]
     }
   ]
  }
}
odoo payment account
2个回答
0
投票

帐户支付向导使用 line_ids 字段,该字段应该使用

active_ids
键通过上下文传递(Odoo 将使用活动 ID 检索帐户移动行)

active_model应该通过上下文传递,如果活动模型与

account.move
account.move.line
不同,Odoo将引发以下错误:

The register payment wizard should only be called on account.move or account.move.line records.

以下示例将使用

Register Payment
按钮中使用的相同逻辑来创建和注册发票付款:

vals = {}
payment_register_id = models.execute_kw(db, uid, password, 'account.payment.register', 'create', [vals], {'context': {'active_model': 'account.move', 'active_ids': invoice_ids}})
models.execute_kw(db, uid, password, 'account.payment.register', 'action_create_payments', [[payment_register_id]])

以下值是我们手动创建付款时传递给创建方法的默认值(使用客户发票表单上的注册付款按钮):

{'can_group_payments': False, 'payment_type': 'inbound', 'partner_type': 'customer', 'source_amount': 365125, 'source_amount_currency': 365125, 'source_currency_id': 2, 'company_id': 1, 'partner_id': 10, 'country_code': 'US', 'journal_id': 7, 'payment_method_id': 1, 'payment_token_id': False, 'partner_bank_id': False, 'group_payment': True, 'amount': 365125, 'currency_id': 2, 'payment_date': '2022-02-04', 'communication': 'INV/2021/12/0001', 'payment_difference_handling': 'open', 'writeoff_account_id': False, 'can_edit_wizard': True, 'writeoff_label': 'Write-Off'}

编辑

您可以调用

execute_kw
方法并在
kwargs

中传递上下文
{'jsonrpc': '2.0', 
 'method': 'call', 
 'params': {
    'service': 'object', 
    'method': 'execute_kw', 
    'args': ('{{databaseName}}', 
              {{userId}}, 
             '{{password}}', 
             'account.payment.register', 
             'create', 
             [{'journal_id': 7, ...}], 
             {'context': {'active_model': 'account.move', 'active_ids': [23]}}
            )
    }, 
    'id': 843350301
}

以下代码基于JSON-RPC库文档示例

import json
import random
import urllib.request

HOST = 
PORT = 
DB = 
USER = 
PASS = 

def json_rpc(url, method, params):
    data = {
        "jsonrpc": "2.0",
        "method": method,
        "params": params,
        "id": random.randint(0, 1000000000),
    }
    req = urllib.request.Request(url=url, data=json.dumps(data).encode(), headers={
        "Content-Type":"application/json",
    })
    reply = json.loads(urllib.request.urlopen(req).read().decode('UTF-8'))
    if reply.get("error"):
        raise Exception(reply["error"])
    return reply["result"]

def call(url, service, method, *args):
    return json_rpc(url, "call", {"service": service, "method": method, "args": args})

# log in the given database
url = "http://%s:%s/jsonrpc" % (HOST, PORT)
uid = call(url, "common", "login", DB, USER, PASS)

args = [{'journal_id': 7}]
kwargs = {'context': {'active_model': 'account.move', 'active_ids': [23]}}

payment_register_id = call(url, "object", "execute_kw", DB, uid, PASS, 'account.payment.register', 'create', args, kwargs)
call(url, "object", "execute", DB, uid, PASS, 'account.payment.register', 'action_create_payments', [payment_register_id])

0
投票

pude hacerlo con esta guia

Se debe hacer en dospartes

© www.soinside.com 2019 - 2024. All rights reserved.