From e1f9afebcaa2363bc6feee8112b12c02ee6db769 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Thu, 19 Oct 2017 17:16:25 +0200 Subject: [PATCH] [FIX] base, website_theme_install: review todo action order Since https://github.com/odoo/odoo/commit/d1fc62df0b850c56360c1e5391c69eb807d0fe46: When several ir.actions.todo are created, only the last one is considered and the first are marked as done. Thus, there are never multiple "open" todos at the same time (while before this, only the first todo was done and the other ones were done on subsequent module installations, which makes no sense). The new system however broke stuff. Indeed, when installing the eCommerce, we expect to land on the "Choose a Theme" page (if website was not already installed). This was not the case anymore, as the last todo in that installation is "Redirect to /shop". To fix the problem, the system is changed to not consider the "last todo" but "the todo with highest priority, or the last one if same priorities". By making the "Choose a theme" todo high priority, this solves the problem. A better system would be to make todos depend on each other... but that would be a task for master. --- addons/website_theme_install/views/views.xml | 1 + odoo/addons/base/ir/ir_actions.py | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/addons/website_theme_install/views/views.xml b/addons/website_theme_install/views/views.xml index d53e1494570..258783a0489 100644 --- a/addons/website_theme_install/views/views.xml +++ b/addons/website_theme_install/views/views.xml @@ -86,6 +86,7 @@ action = { + 0 diff --git a/odoo/addons/base/ir/ir_actions.py b/odoo/addons/base/ir/ir_actions.py index e24ebedba1b..982a0364089 100644 --- a/odoo/addons/base/ir/ir_actions.py +++ b/odoo/addons/base/ir/ir_actions.py @@ -602,18 +602,19 @@ class IrActionsTodo(models.Model): def create(self, vals): todo = super(IrActionsTodo, self).create(vals) if todo.state == "open": - todo.ensure_one_open_todo() + self.ensure_one_open_todo() return todo + @api.multi def write(self, vals): res = super(IrActionsTodo, self).write(vals) if vals.get('state', '') == 'open': - for todo in self: - todo.ensure_one_open_todo() + self.ensure_one_open_todo() return res + @api.model def ensure_one_open_todo(self): - open_todo = self.search(['&', ('state', '=', 'open'), ('id', '!=', self.id)]) + open_todo = self.search([('state', '=', 'open')], order='sequence asc, id desc', offset=1) if open_todo: open_todo.write({'state': 'done'})