İçereği Atla
Menü
Bu soru işaretlendi
844 Görünümler

I have a many-to-many relationship with my Employee and Project models. But since in my intermediate table there must be an attribute called "employee_performance" I had to create an intermediate table to add it and make one2many many2one relationships to simulate this many2many relationship, this is how it looks in code:


class Employee(models.Model):   

​_name = "company.employee"    

​_description = "Employee"

​ name = fields.Char("Name", required=True)

employee_proyect_ids = fields.One2many("company.employee_proyect", "employee_id", string="Proyects") 


class Proyect(models.Model):   

​_name = "company.proyect"    

​_description = "Proyect"

​ name = fields.Char("Name", required=True)

employee_proyect_ids = fields.One2many("company.employee_proyect", "proyect_id", string="Employees") 


class EmployeeProyect(models.Model):   

​_name = "company.employee_proyect"    

​_description = "Employees and Proyects"

​ employee_performance = fields.Integer("Performance", required=True)

employee_id = fields.Many2one("company.employee", string="Employee") 

​proyect_id = fields.Many2one("company.proyect", string="Proyect")



But with this implementation, when, for example, I assign a project to an employee, and then I want to assign another project, the previously selected project appears again to choose from again. On the other hand, when I made the relationship with "many2many" between both tables and made the same project assignment, only the projects that were not assigned to my employee were shown, making it impossible for me to grant him repeated projects. 
And this is the behavior I need but it doesn't work with my implementation, so, how can I achieve this?

Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
1
Ağu 25
902
1
May 25
1641
0
Kas 24
1707
2
Eki 24
1818
0
Ağu 24
1448