跳至內容
選單
此問題已被標幟
1 回覆
3708 瀏覽次數

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.