简体   繁体   中英

Call a python method in record rule Odoo

The common syntax of record rules is ['|',('user_id','=',user.id),('user_id','=',False)]]

Is there any possiblilties we can use a python method to get the dynamic ids of user?

For Example

['|',('user_id','=',getuserid()),('user_id','=',False)]

You can try something like, xml:

['|',('user_id','=', user.env["your.model"].get_userid().id), ('user_id','=',False)]

Py:

def get_userid(self):
    domain = []
    return self.env["res.user"].search(domain)

Let me know if this works for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM