Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
732 Lượt xem
: Many2many fields hr.employee.em_contrat and hr.employee.em_champ use the same table and columns


lors de la migration du module odoo 10  vers 15

code

# -*- coding: utf-8 -*-

from odoo import fields, models, api, _

from odoo.exceptions import ValidationError


class payrollReport(models.Model):

    _name = 'hr.payroll.report'

    _descripion = 'Payroll Report'

    _rec_name = 'report_title'



    rule_ids = fields.Many2many("hr.salary.rule", string=u"Salary Rules", required=True, )#default_order='sequence desc'

    report_title = fields.Char(string=u"Report Title")

    champ = fields.Many2many(comodel_name='ir.model.fields','rel_table1','current_model_id1','country_model_id1', string=u"Employés")

    

    contrat = fields.Many2many(comodel_name='ir.model.fields','rel_table2','current_model_id2','country_model_id2',string=u"Contrats")




-


# -*- coding: utf-8 -*-

from odoo import fields, models, api, _

from odoo.exceptions import ValidationError


class payrollReport(models.Model):

    _inherit = 'hr.employee'

    

    em_champ = fields.Many2many('ir.model.fields',string="Employés")

    

    em_contrat = fields.Many2many('ir.model.fields',string="Contrats")

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hey Cheikh Tidiane Diop,


I hope you are doing well.


This warning will be resolved by defining relation to each of the fields using the same table and columns.

Like you already did in the below fields 

Please find code in comment. 

I hope this will help you.

Thanks & Regards,
Email: odoo@aktivsoftware.com     

Skype: kalpeshmaheshwari

Ảnh đại diện
Huỷ bỏ

Please find code here :-

champ = fields.Many2many(comodel_name='ir.model.fields','rel_table1','current_model_id1','country_model_id1', string=u"Employés")

contrat = fields.Many2many(comodel_name='ir.model.fields','rel_table2','current_model_id2','country_model_id2',string=u"Contrats")

To fix the problem, use the code shown below as a guide to update your code.

em_champ = fields.Many2many('ir.model.fields',’em_champ_rel’,string="Employés")

em_contrat = fields.Many2many('ir.model.fields',’em_contra_relt’,string="Contrats")

Tác giả Câu trả lời hay nhất

Thanks for your answare 

already resolve thanks

Ảnh đại diện
Huỷ bỏ