[FIX] mrp: layout issue in workorder messages

The alert box was flickering if empty: at each click on the status
button, the box was appearing and disappearing quickly. This is probably
due to a bug in the form view that do not wait for the evaluation of the
attrs. This bug is fixed in the new views, but only if the attrs is
fixed. Indeed, as the attrs condition is

    attrs="{'invisible': [('production_messages', '=', False)]}"

the field was never set to False. This is because the compute method was
doing

    workorder.production_messages = "<br/>".join(messages)

So, even if `messages` was empty, production_messages will be set to ''.

In [1]: 'aaa'.join([])
Out[1]: ''

So we fix the condition to set False to the field if the string is
empty.

In [6]: 'aaa'.join([]) or False
Out[6]: False
This commit is contained in:
Simon Lejeune
2017-03-29 10:08:20 +02:00
parent 7a9c4b068c
commit e05333f8f5
+1 -1
View File
@@ -163,7 +163,7 @@ class MrpWorkorder(models.Model):
('bom_id', '=', workorder.production_id.bom_id.id),
('routing_id', '=', workorder.operation_id.routing_id.id)]
messages = ProductionMessage.search(domain).mapped('message')
workorder.production_messages = "<br/>".join(messages)
workorder.production_messages = "<br/>".join(messages) or False
@api.multi
def _compute_scrap_move_count(self):