Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions mrp_bom_lock_used/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
=================
MRP BOM Lock Used
=================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:b9c74cd70264e7189ed9406086ab59225bd28bb65f41f7abdc42031f3e2905da
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github
:target: https://github.com/OCA/manufacture/tree/17.0/mrp_bom_lock_used
:alt: OCA/manufacture
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/manufacture-17-0/manufacture-17-0-mrp_bom_lock_used
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/manufacture&target_branch=17.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

Prevents BOM modifications when active production orders exist and
blocks MO confirmation when BOM is outdated.

Useful when using along with the mrp_bom_version module, to further
enhance BOM version control.

**Table of contents**

.. contents::
:local:

Usage
=====

When you try to modify a BOM that has active production orders, you will
receive an error message listing the affected production orders. You
must complete or cancel these production orders before modifying the
BOM.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/manufacture/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/manufacture/issues/new?body=module:%20mrp_bom_lock_used%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Open Source Integrators

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/manufacture <https://github.com/OCA/manufacture/tree/17.0/mrp_bom_lock_used>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions mrp_bom_lock_used/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).

from . import models
15 changes: 15 additions & 0 deletions mrp_bom_lock_used/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2026 Open Source Integrators
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).

{
"name": "MRP BOM Lock Used",
"version": "17.0.1.0.0",
"author": "Open Source Integrators, Odoo Community Association (OCA)",
"summary": "Prevents BOM modifications when active production orders"
" exist and blocks MO confirmation when BOM is outdated",
"website": "https://github.com/OCA/manufacture",
"category": "Manufacturing",
"depends": ["mrp"],
"license": "LGPL-3",
"installable": True,
}
40 changes: 40 additions & 0 deletions mrp_bom_lock_used/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mrp_bom_lock_used
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-02-20 18:40+0000\n"
"PO-Revision-Date: 2026-02-20 18:40+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: mrp_bom_lock_used
#: model:ir.model,name:mrp_bom_lock_used.model_mrp_bom
msgid "Bill of Material"
msgstr "Nomenclature"

#. module: mrp_bom_lock_used
#: model:ir.model,name:mrp_bom_lock_used.model_mrp_bom_line
msgid "Bill of Material Line"
msgstr "Ligne de nomenclature"

#. module: mrp_bom_lock_used
#. odoo-python
#: code:addons/mrp_bom_lock_used/models/mrp_bom.py:0
#, python-format
msgid ""
"Cannot modify BOM lines. There are active production orders: %s. Please "
"complete or cancel these production orders before modifying the BOM."
msgstr "Impossible de modifier les lignes de nomenclature. Il y a des ordres de fabrication actifs : %s. Veuillez terminer ou annuler ces ordres de fabrication avant de modifier la nomenclature."

#. module: mrp_bom_lock_used
#: model:ir.model,name:mrp_bom_lock_used.model_mrp_production
msgid "Production Order"
msgstr "Ordre de production"
40 changes: 40 additions & 0 deletions mrp_bom_lock_used/i18n/mrp_bom_lock_used.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mrp_bom_lock_used
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-02-20 18:39+0000\n"
"PO-Revision-Date: 2026-02-20 18:39+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: mrp_bom_lock_used
#: model:ir.model,name:mrp_bom_lock_used.model_mrp_bom
msgid "Bill of Material"
msgstr ""

#. module: mrp_bom_lock_used
#: model:ir.model,name:mrp_bom_lock_used.model_mrp_bom_line
msgid "Bill of Material Line"
msgstr ""

#. module: mrp_bom_lock_used
#. odoo-python
#: code:addons/mrp_bom_lock_used/models/mrp_bom.py:0
#, python-format
msgid ""
"Cannot modify BOM lines. There are active production orders: %s. Please "
"complete or cancel these production orders before modifying the BOM."
msgstr ""

#. module: mrp_bom_lock_used
#: model:ir.model,name:mrp_bom_lock_used.model_mrp_production
msgid "Production Order"
msgstr ""
2 changes: 2 additions & 0 deletions mrp_bom_lock_used/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import mrp_bom
from . import mrp_production
77 changes: 77 additions & 0 deletions mrp_bom_lock_used/models/mrp_bom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Copyright 2025 Open Source Integrators
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).

from odoo import _, models
from odoo.exceptions import UserError


class MrpBom(models.Model):
_inherit = "mrp.bom"

def _check_active_production_orders(self):
"""Check for active production orders and raise error if found."""
production_orders = self.env["mrp.production"].search(
[("bom_id", "in", self.ids), ("state", "not in", ["done", "cancel"])],
)

if production_orders:
production_names = ", ".join(production_orders.mapped("name"))
raise UserError(
_(
"Cannot modify BOM lines. "
"There are active production orders: %s. "
"Please complete or cancel these production orders "
"before modifying the BOM."
)
% production_names
)

def write(self, values):
# Check if BOM lines are being modified
if "bom_line_ids" in values:
self._check_active_production_orders()
return super().write(values)


class MrpBomLine(models.Model):
_inherit = "mrp.bom.line"

def write(self, values):
# Check if critical fields are being modified
critical_fields = ["product_id", "product_qty", "product_uom_id"]
if any(field in values for field in critical_fields):
for bom_line in self:
bom = bom_line.bom_id
# Check for existing production orders
production_orders = self.env["mrp.production"].search(
[("bom_id", "=", bom.id), ("state", "not in", ["cancel"])], limit=5
)
if production_orders:
production_names = ", ".join(production_orders.mapped("name"))
raise UserError(
"Cannot modify BOM line '%s' for BOM '%s'. "
"There are active or done production orders: %s. "
"Please complete or cancel these production orders"
" before modifying the BOM line."
) % (bom_line.display_name, bom.display_name, production_names)

return super().write(values)

def unlink(self):
for bom_line in self:
bom = bom_line.bom_id
# Check for existing production orders before deletion
production_orders = self.env["mrp.production"].search(
[("bom_id", "=", bom.id), ("state", "not in", ["done", "cancel"])]
)

if production_orders:
production_names = ", ".join(production_orders.mapped("name"))
raise UserError(
"Cannot delete BOM line '%s' from BOM '%s'. "
"There are active production orders: %s. "
"Please complete or cancel these production orders "
"before removing the BOM line."
) % (bom_line.display_name, bom.display_name, production_names)

return super().unlink()
24 changes: 24 additions & 0 deletions mrp_bom_lock_used/models/mrp_production.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2026 Open Source Integrators
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).

from odoo import models
from odoo.exceptions import UserError


class MrpProduction(models.Model):
_inherit = "mrp.production"

def action_confirm(self):
for production in self:
# Check if BOM is outdated before allowing confirmation
if production.is_outdated_bom:
raise (
UserError(
"Cannot confirm production order '%s'. "
"The BOM is outdated. Please update the BOM "
"or create a new production order."
)
% production.name
)

return super().action_confirm()
3 changes: 3 additions & 0 deletions mrp_bom_lock_used/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
5 changes: 5 additions & 0 deletions mrp_bom_lock_used/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Prevents BOM modifications when active production orders exist and
blocks MO confirmation when BOM is outdated.

Useful when using along with the mrp_bom_version module, to further
enhance BOM version control.
4 changes: 4 additions & 0 deletions mrp_bom_lock_used/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
When you try to modify a BOM that has active production orders, you will
receive an error message listing the affected production orders. You
must complete or cancel these production orders before modifying the
BOM.
Loading
Loading