Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
4 Trả lời
3570 Lượt xem

I have given a field in my backend as selection but while I am choosing my field for the frontend it appears to be a radio button. I need a reason why it's changing and how it can be resolved?

from odoo import models, fields


class Alumni_Form_Record(models.Model):

_name="res.partner"

_inherit='res.partner'

exam=fields.Selection([('icse','ICSE'),('isc', 'ISC')], string="Examination")

yop=fields.Integer(string="Year Of Passing ICSE/ ISC")

my_teachers=fields.Char(string="My Teachers")

qual=fields.Selection([('med','Medical Field'),('it','IT Professional'),('engg','Engineer'),('bs','Banking Sector'),('law','Law'),('edu','Education'),('res','Research'),('oth','Others')], string="Qualification/ Profession Category")

hqh=fields.Char(string="Highest Qualification Held")

som=fields.Char(string="Specialization or Major")

ysk=fields.Char(string="Your Special Skill(In any area of interest)")

clg=fields.Char(string="Institute/ College/ University")

ped=fields.Selection([('job','Job'),('se','Self Employed'),('bus','Business'),('stud','Student'),('hm','House Maker'),('ot','Others')],string="Present Employment Status")

about=fields.Text(string="About Me")


Here in this model.py, you could see qual as selection but in the frontend it appears to be a radio button. The frontend I mean here in the theme using form builder (here, it is create a customer form).

Ảnh đại diện
Huỷ bỏ

Where is code for the frontend website?

Tác giả

There is no need for frontend, after dragging and dropping the form builder and choosing my form (create a customer), I can view my fields in Add an existing parameter because I have inherited res.partner in my model.

Câu trả lời hay nhất

In the XML file, check your selection field does not have widget="radio".

Ex:

<field name="ped" widget="radio"/> # If you see this widget, remove it

If you see such widget in your XML file, remove it and update the module.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi, Aishwarya


As per Odoo "Website Form" extension. By default Odoo selection fields shows as "radio button" in frontend.

https://github.com/odoo/odoo/blob/1f226d111eebf410efb27ceb861e22246fa799b2/addons/website_form/static/src/xml/website_form_editor.xml#L129 

In order to modify this feature. You need to update the existing code or you create a new extension and override the "website_form.field_selection"

Thanks,
Ashish Singh (Team Lead)
Webkul Software Private Limited
Ảnh đại diện
Huỷ bỏ
Tác giả

Thank you, Ashish Singh

Your answer has helped me a lot. Thank you.

Thanks for your kind words Aishwarya .It was really great of you to trust my assistance.

Bài viết liên quan Trả lời Lượt xem Hoạt động
5
thg 9 21
20505
0
thg 11 21
2384
8
thg 3 20
3419
0
thg 10 19
3179
0
thg 10 19
3714