Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create two ManyToMany fields in one Omodel #135

Closed
bipinprajapati opened this issue Mar 30, 2016 · 1 comment
Closed

Create two ManyToMany fields in one Omodel #135

bipinprajapati opened this issue Mar 30, 2016 · 1 comment

Comments

@bipinprajapati
Copy link

public class EmployeeAttendance extends OModel {

    public static final String TAG = AttendanceReport.class.getSimpleName();
    public static final String AUTHORITY = "com.odoo.addons.hremployee.att_report";

    OColumn name = new OColumn("Name", OVarchar.class).setSize(100);
    OColumn employee_id = new OColumn("Name", HrEmployee.class, OColumn.RelationType.ManyToOne);

    OColumn employee_absent_ids = new OColumn("Employees absent", HrEmployee.class,
        OColumn.RelationType.ManyToMany);
    OColumn employee_present_ids = new OColumn("Employees present", HrEmployee.class,
        OColumn.RelationType.ManyToMany);


    public EmployeeAttendance(Context context,  OUser user) {
        super(context, "employee.attendance", user);
    }
}

I have created a model named 'employee.attendance'. Inside it, I have created two Many2Many (employee_present_ids & employee_absent_ids).

Both Many2Many belong to HrEmployee.class.

Now when i execute this code(app), only one table named 'attendance_report_hr_empoyee_rel' is created in local database.

In python we can give many2many table name while field declaration.

Please guide me, How to create two manymany fields of same class in one Omodel?

@bipinprajapati bipinprajapati changed the title Create two ManyToMany fields of same class in one Omodel Create two ManyToMany fields in one Omodel Mar 30, 2016
@dpr-odoo
Copy link
Collaborator

@bipinprajapati issue fixed: 654554a

OColumn test_ids= new OColumn("Partners", ResPartner.class, OColumn.RelationType.ManyToMany)
            .setRelBaseColumn("partner_id")
            .setRelRelationColumn("ref_partner_id")
            .setRelTableName("m2m_rel_table_1");

OColumn test_2_ids= new OColumn("Partners2", ResPartner.class, OColumn.RelationType.ManyToMany)
            .setRelBaseColumn("partner_id")
            .setRelRelationColumn("ref_partner_id")
            .setRelTableName("m2m_rel_table_2");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants