İçereği Atla
Menü
Bu soru işaretlendi
1 Cevapla
2848 Görünümler

Hi everyone,

I´m develop a form in a website and I want to get default values from my custom model to show it in the form of the website.

Controller:

@http.route('/feria/formulario', type="http", auth='public', website=True)
def feria_form(self, **kw):
contact_list = request.env['res.partner'].sudo().search([])
values = {
"contact_list": contact_list,
}
return http.request.render('feria.custom_form', values)

**This function return the list of filled form stored in my module

Model:

class Registro(models.Model):
_name = 'feria.registro'
_description = 'Recopilacion de datos en Feria'

@api.model
def _default_image(self):
image_path = get_module_resource('feria', 'static/src/img', 'default_image.png')
return base64.b64encode(open(image_path, 'rb').read())

name = fields.Char(string='Name', required=True, tracking=True)
image = fields.Image(default=_default_image)
contact_related = fields.Many2one('res.partner', string='Contact', default=[])
email = fields.Char(string='Email', default='@.com', required=True, tracking=True)
phone = fields.Char(string='Teléfono', required=True, tracking=True)
mobile = fields.Char(string='Móvil', required=True, tracking=True)
gender = fields.Char(string="Género", default='male')

** This is my module and I want to get default values from fields like gender and email

Template:



Feria de Materiales 2022































** Using XML/HTML I want to show default values from my model y the form.

After that I want to know if there is a way to change value depends of another field, I mean, If I select a contact_related this automatically get his values like phone, email and etc y display it.

I´m new in Odoo and in the community, if there is something wrong please help me to improve the question. Thanks


Avatar
Vazgeç
En İyi Yanıt

changing the value depending on another field is possible through JavaScript

Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
2
Eyl 21
3163
2
Tem 25
295
4
Haz 25
611
1
Haz 25
885
1
May 25
941