[FIX] event_crm: allow event with company in rules without company

Steps to reproduce:

  - Install `event_crm` module
  - Create an Event with a company
  - Go to `Events > Configuration > Event Lead Rules`
  - Create a new rule and set no company
  - Try to set the event created above for Event field

Issue:

  Event created not displayed as possible value for the Event field.

Cause:

  Because we have `check_company=True` set on `event_id` field, the
  field will be filtered based on the `company_id` field, and since no
  company is set on the rule, events with company will not be listed.

  Commit that introduced the issue: https://github.com/odoo/odoo/commit/0479b2b59466ae1d6d74165345aa3a7dc5de24ed

Solution:

  Revert to the previous behavior (remove `check_company=True` from
  `event_id` field and use a domain instead).

opw-3715864

closes odoo/odoo#154009

X-original-commit: 13cb20dafb6dd473fe71b605a2adf70fa0ac368e
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Signed-off-by: Nasreddin Boulif (bon) <bon@odoo.com>
This commit is contained in:
Nasreddin Boulif (bon)
2024-02-14 18:32:14 +00:00
parent f6f170c483
commit 7ab9d0e468
+1 -1
View File
@@ -93,7 +93,7 @@ class EventLeadRule(models.Model):
help='Filter the attendees to include those of this specific event category. If not set, no event category restriction will be applied.')
event_id = fields.Many2one(
'event.event', string='Event',
check_company=True,
domain="[('company_id', 'in', [company_id or current_company_id, False])]",
help='Filter the attendees to include those of this specific event. If not set, no event restriction will be applied.')
company_id = fields.Many2one(
'res.company', string='Company',