Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
4 Ответы
9085 Представления

I have created a model which one field is "Many2one" type, and its co-model is "res.users":

to_approve_by = fields.Many2one(comodel_name='res.users', string='To Approve by')

On the form view for this model. I want the selection widget of this field only list the 'res.users' in one certain group, such as "Project / Manager".

So, how to editor the code to realize it?

Are there someone give me a sample code or some advice?

Thanks.

Аватар
Отменить

use domain filter for the field

Лучший ответ

Hi,

try something like this (not tested) :

def _get_users_group_project(self):
    return [('id', 'in', self.env.ref('xml_id_of_group').users.ids)]

to_approve_by = fields.Many2one('res.users', string='To Approve by', domain=lambda self:self._get_users_group_project())

Regards

Аватар
Отменить
Автор Лучший ответ

Dear Mohammed Amal,

Did your means that I should code my .py file like below?:

to_approve_by = fields.Many2one(comodel_name='res.users',
string='To Approve by',
domain="[('groups_id.ids','??',??)]")

But I don't know how to code the 'operator' and 'value' section in the tuple. So, Would your please give me a sample?

Аватар
Отменить
Related Posts Ответы Просмотры Активность
0
июл. 25
283
0
апр. 25
760
2
февр. 25
5846
1
дек. 24
1410
1
июл. 24
2194