Se rendre au contenu
Menu
Cette question a été signalée
1 Répondre
1782 Vues

Anyone know if it is possible to default the Salesperson when adding a new contact using domain? 


We are on v15 and typically use studio for edits.

Thanks.

Avatar
Ignorer

hello
are you found the solution for this ?

Meilleure réponse

Hi,

If you like to set a default value in XML, for a particular page or view, then you can consider the following option: In the "action" record that opens your Form View, you can add an entry in a "context" dictionary, like this:

<field name="context">{'default_user_id': uid}</field>

OR

use default=lambda self: self.env.user in the field

OR

In defaults, you can only set a default value for the field and not the domain. Instead, u can do the other way, add another field which will fetch the domain value and that field tries to use it as a domain to your fields.

current_user_id = fields.Many2one('res.users', default=lambda self: self.env.user)
user_id = fields.Many2one('res.users', domain="[('user_id', '=', current_user_id)]")

Regards

Avatar
Ignorer