[FIX] crm: restrict opportunity merge salesperson choice

Steps to reproduce issue:

1. Open CRM and select a list/tree view (opportunities or leads)
2. Select multiple records and try merging them (gear menu)
3. Click on salesperson field
4. Field dropdown contains portal users, should not be the case

Explanation:

`user_id` (salesperson field) in `crm.merge.opportunity` is a many2one related to res.users. Since it is not restricted, every existing user is listed in the selection.

Suggested fix:

In `crm.lead`, its homologous field possesses the domain formula `('share', '=', False)`.
https://github.com/odoo/odoo/blob/f987dd26e928bd0394cd0b835cc1d0fdd72e9234/addons/crm/models/crm_lead.py#L105-L108
Copying it into `crm.merge.opportunity` correctly restricts the users selection.

opw-3696148

closes odoo/odoo#153230

X-original-commit: e43d13d8aae2b46107237102e9f45a4c8e8e39df
Signed-off-by: Stroobant Paul (stpa) <stpa@odoo.com>
This commit is contained in:
Paul Stroobant
2024-02-09 08:54:51 +00:00
parent 432778725d
commit e7653c86aa
+1 -1
View File
@@ -33,7 +33,7 @@ class MergeOpportunity(models.TransientModel):
return result
opportunity_ids = fields.Many2many('crm.lead', 'merge_opportunity_rel', 'merge_id', 'opportunity_id', string='Leads/Opportunities')
user_id = fields.Many2one('res.users', 'Salesperson')
user_id = fields.Many2one('res.users', 'Salesperson', domain="[('share', '=', False)]")
team_id = fields.Many2one(
'crm.team', 'Sales Team',
compute='_compute_team_id', readonly=False, store=True)