Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
2879 มุมมอง

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


อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

changing the value depending on another field is possible through JavaScript

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ก.ย. 21
3210
Carrusel en sitios web แก้ไขแล้ว
2
ก.ค. 25
424
How to launch my website แก้ไขแล้ว
4
มิ.ย. 25
684
1
มิ.ย. 25
980
1
พ.ค. 25
1006