Skip to Content
Menu
This question has been flagged
2 Replies
2144 Views

Hello everyone,


I have a problem about adding filter on many2one field based another field in another table, I want to filter the jobposition_id so the field just showing the data that have a status "Kurang" can anybody help me?, thank you, this is my model :


class Lowongan(models.Model):

    _name = "mouse.lowongan"

    _rec_name = "jobposition_id"


    jobposition_id = fields.Many2one(comodel_name="mouse.jobposition", string="Posisi", ondelete="cascade")


class JobPosition(models.Model):

    _name = "mouse.jobposition"

    _rec_name = "namajob"


    status = fields.Selection([("Kurang","Kurang"),("Penuh","Penuh")], "Kebutuhan Jumlah Karyawan", readonly=True, compute="status_capacity")

Avatar
Discard
Author

Hello,

I have tried it, but it didn't work, the many2one field still showing all data, not filtered depends status

Best Answer

Hi, 

simply do this: 

jobposition_id = fields.Many2one(comodel_name="mouse.jobposition", string="Posisi", ondelete="cascade", domain="[('status, '=', 'kurang')]")

Avatar
Discard