Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
3705 มุมมอง

Dear All,

      I' a newbie for ODOO. I'm trying to develop my knowledge. Then I make a personal project name "My Recruitment". 

I'v inherited model "hr.applicant" and add new field name "x_place". 

I'd like limit the user to see only the record that user is member of Many2Many name "my.recruitment.place".


I'm create Record Rules with the following 



It's working fine with my test ir.rule

['|',('x_place','in',[1,2,3,4]),('x_place','=',False)]



but I expect the result 


xxx = self.env['my.recruitment.place'].search([('res_users_id','=',user.id)])


['|',('x_place','in',[xxx]),('x_place','=',False)]




class MYRecruitment(models.Model):

_inherit = ['hr.applicant']

    x_place = fields.Many2one('my.recruitment.place', "Place")

class MyRecruitmentPlace(models.Model):

    _name = "my.recruitment.place"

    _description = "Place of Recruitment"

    _sql_constraints = [

        ('name_uniq', 'unique (name)', 'The name of the place of Recruitment must be unique!')

    ]


    name = fields.Char("Place", required=True, translate=True)

    user_ids = fields.Many2many('res.users', string="Owners")

    sequence = fields.Integer("Sequence", default=1, help="Gives the sequence order when displaying a list of place.")

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Try it bro:
xxx = self.env['my.recruitment.place'].search([('user_ids','=',user.id)])

อวตาร
ละทิ้ง
ผู้เขียน

Thank you. But I does not work.