Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
6012 Widoki

Hello,

I am trying to create new view for survey module for that i have inherit survey_formview.

I am using first xpath to remove notebook from view and second xpath add two fields after title field. But notebook not removed and also other view is created for two fields add into xpath.

At same time base form view is also changed as per custom view.

Following is my code:

py file:

from odoo import models, fields, api

class SurveyCreate (models.Model):

_name = 'survey.survey'

_inherit = [ 'survey.survey' , 'survey.question' ]

XML file:

<? 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.survey </field>

<field name = "view_type" > form </field>

<field name = "priority" > 8 </field>

<field name = "inherit_id" ref = "survey.survey_form" />

<field name = "mode" > primary </field>

<field name = "arch" type = "xml" >

<form>

<xpath expr = "// form / sheet / notebook / page [1]" position = "replace" >

</xpath>

<xpath expr = "// form / sheet / div / label / h1 / field [@ name = 'title']" position = "after" >

<div>

<group>

<field name = "question" />

<field name = "type" />

</group>

</div>

</xpath>

</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.survey </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" string = "Survey Create" action = "survey_create_action" />

</data>

</odoo>



Question:

1. Not understand why two view are created

2. Why Notebook is not removed.

3. Why base view is change if i am using <field name = "mode" > primary </field>




Awatar
Odrzuć

Try to uninstall your module and check if the views are exists. then install it again and check.

Najlepsza odpowiedź
  • Bind Your Custom view with action. For Example

<record model="ir.actions.act_window.view" id="test_action_tree">
   <field name="sequence" eval="1"/>
   <field name="view_mode">tree</field>
   <field name="view_id" ref="view_test_tree"/>
   <field name="act_window_id" ref="test_action"/>
</record>
Awatar
Odrzuć
Autor

Thanks @Hilar AK for your replay. My issue is nit resolve as per your suggestion. and it also change base view(default view) as per custom view.

Powiązane posty Odpowiedzi Widoki Czynność
1
sie 21
3176
3
lis 23
17272
3
lis 24
24858
1
kwi 23
6050
2
gru 22
6753