Skip to Content
Menu
This question has been flagged

Hi everyone.

I have a query here to find ad answer to solve my problem.

I have defined a field 'Type' as selection with values (TDS, ESI, PF, Professional Tax). I need to restrict users to select only particular values.For example, One user named 'Dany' can be able to select only (TDS and ESI) values. So how can we achieve this based on user rights? Give me ideas to achieve this Solution. Thanks in advance.


Avatar
Discard

It'll be better if you create a many2one with domain and in view give widget="selection".

Author

Hello i mean to hide other two values for that user(PF and Prfofessional Tax).

Best Answer

On the XML level it is not possible, however, you can achieve that by re-defining the type field. The goal is populate selection values in the method. E.g.:


def get_ttype_selection(self):
    res = []
    if self.env.user.name == 'Dany':
        res = [("option1", "TDS"), ("option2", "ESI")]
    else:
        res = [("option3", "PF"), ("option4", "Professional Tax")]
    return res
ttype = fields.Selection(get_ttype_selection)
Avatar
Discard
Author

I dont wanna hardcore names in code. I need this to be achieved through some settings method.

Related Posts Replies Views Activity
1
Apr 22
911
0
Jul 21
2881
0
Oct 19
1562
2
Aug 24
280
2
Apr 24
1407