0
votes

I'm currently building a module like a project module which shows Kanban view for model 'test.project' and when I click Kanban view, It shows tree views for model 'test.task' related to 'test.project'.

So I made a code below

class Test_project(osv.osv):

    _name = "test.project"
    _columns = {
        'name': fields.char('Name'),
        'task_ids': fields.one2many('test.task', 'project_id', string='TASK')
    }

class Test_Task(osv.osv):

    _name = 'test.task'
    _columns = {
        'project_id': fields.many2one('test.project', string='Project ID', required=1),
    }

When I saved a data for 'test.project', It is saved correctly, But When I saved a data for 'test.task', It shows an error which is

IntegrityError: null value in column "project_id" violates not-null constraint

Cannot get the id.

1
in your 'test.task' project_id is required so while creating record for 'test.task' project_id=False so its give this errorAlpesh Valaki
@ADVALAKI Then how do you get project_id while creating a record for 'test.task'?Eric Lee

1 Answers

1
votes

You have set required=1 on the definition of the project_id field. That means that every time you create and save a record you will have to give a value to that fields otherwise you will not be able to save it.