0
votes

I have multiple Many2many fields but I'm getting the following error:

relation stream doesn't exist,undefined-table

I cannot find where this error is occurring. Can someone help me fix this error?

class College(models.Model):
_name = 'module5_college'
_description = 'College Info'
_rec_name = 'clg'

clg = fields.Char("College Name")
uni = fields.Char("Affiliated to")
cou = fields.Many2many('module5_stream',string="Stream")


class Stream(models.Model):
_name = 'module5_stream'
_description = 'Stream info'
_rec_name = 'cou'

cou = fields.Selection([
    ('BTECH', 'BTECH'),
    ('MTECH', 'MTECH'),
    ('MCA', 'MCA')],"Stream")

cou_mode = fields.Selection([
    ('Regular','Regular'),
    ('Lateral','Lateral'),
    ('Distance','Distance')],"Course Mode")

sem_no = fields.Integer("No of semesters")
# full_score = fields.Integer(compute='score_calc',string="Score")
sem = fields.Many2many('module5_sem',"Semesters")


class Semester(models.Model):
 _name = 'module5_sem'
 _rec_name = 'id'

 sem_no = fields.Char("Semester No")
 sub = fields.Many2many('module5_subject',"Subjects")
1

1 Answers

0
votes

You have to follow this example because this is the way to create many2many field:

employees_ids = fields.many2many('Employees.Employees', 'tasks_employees_rel', 'task_id', 'employee_id', 'Employees assigned to task')

To give you a better example.

A employee can be assigned to many tasks

A task can be assigned to many employees

So you have a many2many relation, so that means that you have to create a new table containing both keys.