Skip to content

Commit

Permalink
[FIX] core: fix _get_default_calendar_view
Browse files Browse the repository at this point in the history
Due to odoo#51075 it's an error to assign the `_date_name` field on
an empty recordset.

```
 Traceback (most recent call last):
   File "/home/odoo/src/odoo/14.0/odoo/models.py", line 1582, in _fields_view_get
    arch_etree = getattr(self, '_get_default_%s_view' % view_type)()
   File "/home/odoo/src/odoo/14.0/odoo/models.py", line 1495, in _get_default_calendar_view
    self._date_name = dt
 AttributeError: 'project.phase' object attribute '_date_name' is read-only
```

Issue observed on upgrade requests 2615 and 3121.

closes odoo#73401

X-original-commit: 1bbe887
Signed-off-by: Christophe Simonis <chs@odoo.com>
Co-authored-by: Christophe Simonis <chs@odoo.com>
  • Loading branch information
aj-fuentes and KangOl committed Jul 7, 2021
1 parent 4fa4ff6 commit 6597b8c
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions odoo/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1587,15 +1587,9 @@ def set_first_of(seq, in_, to):
view = E.calendar(string=self._description)
view.append(E.field(name=self._rec_name_fallback()))

if self._date_name not in self._fields:
date_found = False
for dt in ['date', 'date_start', 'x_date', 'x_date_start']:
if dt in self._fields:
self._date_name = dt
break
else:
raise UserError(_("Insufficient fields for Calendar View!"))
view.set('date_start', self._date_name)
if not set_first_of([self._date_name, 'date', 'date_start', 'x_date', 'x_date_start'],
self._fields, 'date_start'):
raise UserError(_("Insufficient fields for Calendar View!"))

set_first_of(["user_id", "partner_id", "x_user_id", "x_partner_id"],
self._fields, 'color')
Expand Down

0 comments on commit 6597b8c

Please sign in to comment.