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

Hello,
I have created new model. In that model inherit other model. Which means my model contain fields of inherited model. Now i am creating form view of my custom model and in that form view display inherited model field.
But the problem is that after displaying field in view it will display their default view.
Following is code:

sample.py

from odoo import models,fields

class SurveyCreate(models.Model):

_name = 'survey.create'
_inherit = ['survey.survey','survey.question','survey.page']



sample_view.Xml


<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<data>

<record id="survey_create_form" model="ir.ui.view">
<field name="name">Survey Form</field>
<field name="model">survey.create</field>
<field name="arch" type="xml">
<form>
<sheet>
<group><!-- survey.survey -->
<field name="title"/>
</group>

<group>
<h2>survey_survey one2many </h2>
<field name="page_ids" mode="tree"/>
<tree>
<field name="title"/>
<field name="question_ids"/>
<control>
<create name="Add Page"/>
</control>
</tree>
</group>

<group col="4" colspan="2"><!-- survey.question -->
<field name="question"/>
<field name="type"/>
</group>
</sheet>
</form>
</field>
</record>

<record id="survey_create_action" model="ir.actions.act_window">
<field name="name">Survey Action</field>
<field name="res_model">survey.create</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="help" type="html">
<p class="oe_view_noncontent_create">
Create Survey
</p>
</field>
</record>

<menuitem id="main_menu" name="Survey Create" action="survey_create_action"/>
</data>
</odoo>

I hope provided description is clear. If not then please let me know.

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

why you need inherit three model into one new custom model? what you want to accomplish?

อวตาร
ละทิ้ง
ผู้เขียน

I want to create custom form view from that user can able to create survey. means form view contain survey title, survey pages, survey questions.

คำตอบที่ดีที่สุด

\https://www.odoo.com/forum/help-1/question/after-inheritance-and-create-new-view-it-shows-all-fields-132318 \

you should open this thread may it will helps you

อวตาร
ละทิ้ง
ผู้เขียน

Thanks for your ans. I want to inherit three model into one model(custom model) and create new form view for the fields that inherit in my model.The solution you provide it inherit form view of exiting model

Related Posts ตอบกลับ มุมมอง กิจกรรม
How to track One2many field in Odoo12? แก้ไขแล้ว
3
พ.ย. 23
17278
Error: Couldn't load module web แก้ไขแล้ว
3
พ.ย. 24
24862
How I get the current ID of a record ? แก้ไขแล้ว
1
เม.ย. 23
6050
2
ธ.ค. 22
6757
1
พ.ย. 22
3918