Skip to content

Commit

Permalink
[FIX] mrp: display a warning when archiving a used work center
Browse files Browse the repository at this point in the history
If a work center is used in any routing, a warning will be displayed when it will be archived

opw-2658596

closes odoo#79087

Signed-off-by: Arnold Moyaux <arm@odoo.com>
  • Loading branch information
DjamelTouati committed Oct 29, 2021
1 parent c594c9a commit a05f4e0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
9 changes: 9 additions & 0 deletions addons/mrp/i18n/mrp.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2709,6 +2709,15 @@ msgstr ""
msgid "Not to restrict or prefer quants, but informative."
msgstr ""

#. module: mrp
#: code:addons/mrp/models/mrp_workcenter.py:0
#, python-format
msgid ""
"Note that archived work center(s): '%s' is/are still linked to active Bill "
"of Materials, which means that operations can still be planned on it/them. "
"To prevent this, deletion of the work center is recommended instead."
msgstr ""

#. module: mrp
#: model:ir.model.fields,field_description:mrp.field_mrp_bom__message_needaction_counter
#: model:ir.model.fields,field_description:mrp.field_mrp_production__message_needaction_counter
Expand Down
17 changes: 17 additions & 0 deletions addons/mrp/models/mrp_workcenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,23 @@ def _get_first_available_slot(self, start_datetime, duration):
remaining -= interval_minutes
return False, 'Not available slot 700 days after the planned start'

def action_archive(self):
res = super().action_archive()
filtered_workcenters = ", ".join(workcenter.name for workcenter in self.filtered('routing_line_ids'))
if filtered_workcenters:
return {
'type': 'ir.actions.client',
'tag': 'display_notification',
'params': {
'title': _("Note that archived work center(s): '%s' is/are still linked to active Bill of Materials, which means that operations can still be planned on it/them. "
"To prevent this, deletion of the work center is recommended instead.", filtered_workcenters),
'type': 'warning',
'sticky': True, #True/False will display for few seconds if false
'next': {'type': 'ir.actions.act_window_close'},
},
}
return res


class MrpWorkcenterProductivityLossType(models.Model):
_name = "mrp.workcenter.productivity.loss.type"
Expand Down

0 comments on commit a05f4e0

Please sign in to comment.