[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.
This commit is contained in:
@@ -86,6 +86,7 @@ action = {
|
||||
</record>
|
||||
<record id="theme_install_todo" model="ir.actions.todo">
|
||||
<field name="action_id" ref="theme_install_todo_action"/>
|
||||
<field name="sequence">0</field>
|
||||
</record>
|
||||
|
||||
<!-- Add link to theme install in default customize modal -->
|
||||
|
||||
@@ -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'})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user