コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
2828 ビュー

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

アバター
破棄
関連投稿 返信 ビュー 活動
2
9月 21
3146
2
7月 25
218
4
6月 25
544
1
6月 25
841
1
5月 25
896