如何使用one2many字段为many2one字段设置域

时间:2018-07-19 09:22:02

标签: xml odoo odoo-8

我想为XML中的journal_id设置域。我使用One2many字段获取journal_id的ID,并将域设置为('id','in',journal_voucher_id),但会引发错误

TypeError: not all arguments converted during string formatting

以下是python代码:

journal_voucher_id=fields.One2many('account.journal',compute='default_journalid')

@api.depends('company_id')
def default_journalid(self):
    journal_obj = self.env['account.journal']
    journal_ids = journal_obj.search([('company_id','=',self.company_id.id)])
    self.journal_voucher_id=journal_ids

和XML代码如下:

<field name="journal_id" position="after">
    <field name="journal_voucher_id" invisible="1"/>
</field>

<xpath expr="/form/sheet/group/group/field[@name='journal_id']" position="replace">
    <field name="journal_id" domain="[('type','in',['bank', 'cash']),('id','in',journal_voucher_id)]"
           widget="selection" on_change="onchange_journal(journal_id, line_cr_ids, False, partner_id, date, amount, type, company_id, context)" string="Payment Method"/>
</xpath>

0 个答案:

没有答案