When click on save button gives me odoo server error shown in screenshot and at backed following error display.
2019-12-14 12:36:25,426 4067 ERROR work_span odoo.sql_db: bad query: INSERT INTO "survey_page" ("id", "create_uid", "create_date", "write_uid", "write_date", "create_id_survey", "sequence", "title") VALUES (nextval('survey_page_id_seq'), 1, (now() at time zone 'UTC'), 1, (now() at time zone 'UTC'), 1, 10, 'test1') RETURNING id ERROR: null value in column "survey_id" violates not-null constraint DETAIL: Failing row contains (5, 1, test1, null, 10, null, 1, 2019-12-14 12:36:25.421912, 1, 2019-12-14 12:36:25.421912).
UPDATE Description: I am trying to display survey title, survey page, survey question in one form for that I have create my custom model. Custom model inherit survey.survey,survey.page,survey.question and also contain two one2many field.
Following is my code:
py file
class SurveyCreate(models.Model):
_name = 'create.survey'
_inherit = ['survey.survey','survey.page','survey.question']
pages_id = fields.One2many('survey.page','create_id_survey','Pages')
questions_survey = fields.One2many('survey.question','create_id_survey','Questions')
survey_id = fields.Many2one('survey.survey', string='Survey',required=False)
page_id = fields.Many2one('survey.page', string='Survey page', required=False)
Xml file
<sheet>
<group>
<field name="title"/>
</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" context="{'tree_view_ref':'survey_inherit.survey_create_form','default_page_id':active_id}"/>
</tree>
</field>
</group>
<group>
<field name="questions_survey" mode='tree'>
<tree name="questions_tree" editable="bottom">
<control>
<create string="Add Question"/>
</control>
<field name="question"/>
<field name="type"/>
</tree>
</field>
</group>
<group>
<group>
<field name="question"/>
</group>
<group>
<field name="type"/>
</group>
</group>
</sheet>
</form>
as per @Atul suggestion make changes but same error occur Following screenshot for 1.Form View 2.Error after click on save button
survey_id
, and the column cannot be NULL. – Martinpages
(one2many field) and how you fill it with values. – Kenly