Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
2856 Visualizzazioni

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
Abbandona
Risposta migliore

changing the value depending on another field is possible through JavaScript

Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
2
set 21
3181
2
lug 25
351
4
giu 25
637
1
giu 25
921
1
mag 25
955