-1

以下のコードは、テキストボックスにestates [0].idのみを示しています。フィールドにすべての値をロードする必要があります。そのようなことを行う方法。反復してフィールド値に追加する方法。

def on_change_company(self, cr, uid, ids, company_id, context=None):
    if not company_id:
        return {'value': {
            'bpl_estate_id': False
        }}
    company = self.pool.get('bpl.company.n.registration').browse(cr, uid, company_id, context=context)
    estates = company.estates
    if estates:
        return {
                'value': {
                          'bpl_estate_id': estates[0].id
                          }
                }
    else:
        return {
                'value': {
                          'bpl_estate_id': 0
                          }
                }
4

1 に答える 1

1

あなたの辞書では、あなたはあなたの辞書に置くだけですestates[0].id。IDのリストが必要な場合は、リスト内包表記を使用してください。

if estates:
    return {'value': {'bpl_estate_id': [e.id for e in estates] } }
# rest of code
于 2013-03-24T15:51:43.007 に答える