Auto fill some fields in form when you found id of

2019-04-15 21:28发布

I try to create a simple function who try to fill specific fields in own form when I select the ID of patient registered in other form/module. I put an example:

Module Registro: (create patient)

(automatic generation ID and visible)

-Nombre:

-Email:

-Teléfono:

(save)

Admisión module:

(Open new form)

-ID: select id

(function for auto fill the next fields)

-Nombre: nombre (registro)

-Email: email(registro)

-Teléfono: teléfono(registro)

Use the new API Odoo 8.0 I try this, but doesn't work with message: error 500 type.

función autocompletar campos

@api.onchange('telefono_contacto','persona_contacto','email','nombre_acompanante') # mete campos a afectar
def autofill(self):
    # comdición; si esta con el id seleccionado
    # self.id_anamnesis
    # llenar los campos con los correspondientes del id
    # self.telefono_contacto =''
    # self.persona_contacto = ''
    # self.email = ''
    # self.nombre_acompanante = ''
    pass # aquí la lógica

(La plataforma es Odoo 8.0, S.O: Ubuntu 14.04)

Thank you and best reegards, Marco García Baturan.

标签: forms odoo-8
1条回答
Explosion°爆炸
2楼-- · 2019-04-15 21:51
product_id = fields.Many2one("myproduct.model",string="Product", required=True)
description = fields.Char("Description", related="product_id.description", store=True)
  • It is done using related="......"
  • What I have done is When I select my product it will automatically set description of that particular product.
  • So you need to add related where you want to auto fill.
  • If you set store=True then description is store into database.

enter image description here

查看更多
登录 后发表回答