我想检索“ id”实际上是伙伴。
通过我的功能,我使用了onchange()
装饰器,但是,要使其正常工作,我必须设置硬值。
我尝试过:
print self.partner_id.id
print self.partner_id
它发送给我:
<odoo.models.NewId object at 0x7fa382596090>
res.partner(<odoo.models.NewId object at 0x7fa382596090>
这是我的功能:
# Récupère le foyer actif
@api.onchange('foyer_members')
def _get_active_foyer(self):
for record in self:
if record.foyer_members:
print self.partner_id.id
print self.partner_id
records_foyer_id = self.env['horanet.relation.foyer'].search([('partner_id', '=', 145536)], limit=1)
print records_foyer_id
我的字段:
partner_id = fields.Many2one(string="Child", comodel_name="res.partner")
foyer_members = fields.Many2one(string='Foyers members',
comodel_name="res.partner",
ondelete='restrict',
domain="[('company_type','=','foyer')]",
delegate=False)
该怎么做?谢谢!