简体   繁体   English

多个银行账户时如何调用银行信息

[英]How to call bank informations when there are more than one bank account

I'm working with Odoo 14 eCommerce module for shop and I'm customising email template (Sales: Order Confirmation).我正在为商店使用 Odoo 14 电子商务模块,我正在自定义 email 模板(销售:订单确认)。

I would like to show bank information which are already inserted on Accounting / Bank Accounts section of the company contact information such as;我想显示已经插入公司联系信息的会计/银行账户部分的银行信息,例如; bank name, account holder name, account number etc.银行名称、账户持有人姓名、帐号等。

I'm calling those values like this in the template:我在模板中这样调用这些值:

${object.company_id.bank_ids.acc_holder_name}
${object.company_id.bank_ids.bank_name}
${object.company_id.bank_ids.acc_number}

When there is only one bank account defined, I get the right values without problem, but as soon as I add a second bank account, I get this error below:当只定义了一个银行账户时,我可以毫无问题地获得正确的值,但是一旦我添加第二个银行账户,就会出现以下错误:

Failed to render template : Expected singleton: res.partner.bank(2, 3)

I understand that there are id s of bank accounts, but I don't know what is the right way to indicate the id of the bank account which I want to get the value.我知道有id的银行账户,但我不知道什么是指示我想要获得价值的银行账户的 id 的正确方法。 Any idea?任何的想法?

You should loop over the bank records in the email template, this way:您应该以这种方式循环遍历 email 模板中的银行记录:

% for bank in object.company_id.bank_ids:
    <li>${bank.acc_holder_name}</li>
    <li>${bank.bank_name}</li>
    <li>${bank.acc_number}</li>
% endfor

If you want to do some action inside the loop depending on the ID of the bank account you should do this:如果您想根据银行帐户的 ID 在循环内执行某些操作,您应该这样做:

% for bank in object.company_id.bank_ids:
    % if bank.id == 2:
        <li>${bank.acc_holder_name}</li>
        <li>${bank.bank_name}</li>
        <li>${bank.acc_number}</li>
    % endif
% endfor

However, performing an action depending on the database ID is not recommended since your module may won't work in any database.但是,不建议根据数据库 ID 执行操作,因为您的模块可能无法在任何数据库中运行。 You must value yourself if it's worth it in this particular case.如果在这种特殊情况下值得,您必须重视自己。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM