diff options
| author | xmo-odoo <xmo@odoo.com> | 2017-05-10 09:39:55 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-05-10 09:39:55 +0200 |
| commit | fffaf735f58f1ac57781c095eb552de6d1fcdc47 (patch) | |
| tree | 88ab0ab65430d871862a836524e0ecc890d1674d /addons/project_issue/models/project_issue.py | |
| parent | 10eee18a047d35305dc46282e610e88936d81ffc (diff) | |
[FIX] P3: list -> iterable builtins (#16811)
In Python 3:
* various builtins and dict methods were changed to return
view/iterable objects rather than lists
* and the separate Python 2 view/iterable builtins and methods were
removed altogether
This is problematic when using these items as list (which the happens
repeatedly in Odoo), but more viciously when iterating *multiple times*
over them (which also happens, which I've messed up multiple times while
writing this, and which is a pain to debug even when you've just created
the issue).
Convert all code using these to semantics-matching cross-version
helper functions to get the LCD behaviour between P2 and P3, and
forbid the builtins via lint.
issue #8530
Diffstat (limited to 'addons/project_issue/models/project_issue.py')
| -rw-r--r-- | addons/project_issue/models/project_issue.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/addons/project_issue/models/project_issue.py b/addons/project_issue/models/project_issue.py index 5e4a8757d68..5513e4393ee 100644 --- a/addons/project_issue/models/project_issue.py +++ b/addons/project_issue/models/project_issue.py @@ -278,7 +278,7 @@ class ProjectIssue(models.Model): def email_split(self, msg): email_list = tools.email_split((msg.get('to') or '') + ',' + (msg.get('cc') or '')) # check left-part is not already an alias - return filter(lambda x: x.split('@')[0] not in self.mapped('project_id.alias_name'), email_list) + return [x for x in email_list if x.split('@')[0] not in self.mapped('project_id.alias_name')] @api.model def message_new(self, msg, custom_values=None): @@ -303,7 +303,7 @@ class ProjectIssue(models.Model): issue = super(ProjectIssue, self.with_context(create_context)).message_new(msg, custom_values=defaults) email_list = issue.email_split(msg) - partner_ids = filter(None, issue._find_partner_from_emails(email_list)) + partner_ids = [p for p in issue._find_partner_from_emails(email_list) if p] issue.message_subscribe(partner_ids) return issue @@ -311,7 +311,7 @@ class ProjectIssue(models.Model): def message_update(self, msg, update_vals=None): """ Override to update the issue according to the email. """ email_list = self.email_split(msg) - partner_ids = filter(None, self._find_partner_from_emails(email_list)) + partner_ids = [p for p in self._find_partner_from_emails(email_list) if p] self.message_subscribe(partner_ids) return super(ProjectIssue, self).message_update(msg, update_vals=update_vals) @@ -351,7 +351,7 @@ class ProjectIssue(models.Model): except Exception: pass if self.project_id: - current_objects = filter(None, headers.get('X-Odoo-Objects', '').split(',')) + current_objects = [h for h in headers.get('X-Odoo-Objects', '').split(',') if h] current_objects.insert(0, 'project.project-%s, ' % self.project_id.id) headers['X-Odoo-Objects'] = ','.join(current_objects) if self.tag_ids: |
