Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
1 Balas
2851 Tampilan

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
Buang
Jawaban Terbai

changing the value depending on another field is possible through JavaScript

Avatar
Buang
Post Terkait Replies Tampilan Aktivitas
2
Sep 21
3174
2
Jul 25
332
4
Jun 25
625
1
Jun 25
892
1
Mei 25
946