This question has been flagged
2 Replies
6072 Views

@page { margin: 2cm } p { margin-bottom: 0.25cm; line-height: 115% } a:link { so-language: zxx }

Hello,

I have one2many field in my custom model. In one2many field contain other many2many field.

Custom model contain one more one2many field.


When i am select field of many2many field then data of many2many field is display on custom model another one2many field.


Folowing is my code.


from odoo import models,fields, api


class SurveyCreate(models.Model):

_name = 'create.survey’

survey_name = fields.Many2one('survey.survey',string='Survey Title')

pages_id = fields.One2many('survey.page','create_id_survey','Pages')

questions_survey = fields.One2many('survey.question','create_id_survey','Questions')


@api.onchange('pages_id')

def page_onchange_question(self):

self.questions_survey = self.env['survey.question'].search([('question','=','questions_id')])




<group>

<field name="survey_name"/>

</group>

<group>

<field name="pages_id" mode="tree">

<tree editable="bottom">

<control>

<create string="Add page"/>

</control>

<field name="title"/>

<field name="questions_id" widget="many2many_tags" options="{'no_create':True}" context="{'tree_view_ref':'survey_inherit.questions_survey'}"/> <!--context="{'tree_view_ref':'survey_inherit.questions_tree'}" -->

</tree>

</field>

</group>

<group>

<field name="questions_survey" mode='tree'>

<control>

<create string="Add Question"/>

</control>

<tree name="questions_tree" editable="bottom">

<field name="question"/>

<field name="type"/>

</tree>

</field>

</group>




Avatar
Discard
Best Answer

Hi, i have similiar question, maybe you or someone else knows the answer, how to update one2many based on many2many record? So i want to display record from many2many in one2many field

if anyone knows, I would be very grateful.

Avatar
Discard
Best Answer

on your many2many field add widget many2many_tags also

like example
<field name='type' widget='many2many_tags'/>

Avatar
Discard