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
93 changes: 93 additions & 0 deletions bom_product_revision/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
===============================
BOM Product Revision Management
===============================

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

.. |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/license-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faxls--oca-lightgray.png?logo=github
:target: https://github.com/OCA/axls-oca/tree/wng-add-revision-functions/bom_product_revision
:alt: OCA/axls-oca
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/axls-oca-wng-add-revision-functions/axls-oca-wng-add-revision-functions-bom_product_revision
: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/axls-oca&target_branch=wng-add-revision-functions
:alt: Try me on Runboat

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

This module extends the functionality of the product_revision module to include
revision information in BOM lines.

Features:


* Adds revision information to BOM lines
* Automatically sets the latest revision information when a BOM line is created
* Allows users to change the revision after saving the BOM

**Table of contents**

.. contents::
:local:

Known issues / Roadmap
======================

* Add support for filtering BOMs by revision
* Add support for copying revisions when copying BOMs
* Add support for revision history in BOMs

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/axls-oca/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/axls-oca/issues/new?body=module:%20bom_product_revision%0Aversion:%20wng-add-revision-functions%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
~~~~~~~

* Axelspace

Contributors
~~~~~~~~~~~~

* `Axelspace Corporation <https://www.axelspace.com>`__:

* WangTKurata <takahiko.kurata@axelspace.com>

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/axls-oca <https://github.com/OCA/axls-oca/tree/wng-add-revision-functions/bom_product_revision>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions bom_product_revision/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
20 changes: 20 additions & 0 deletions bom_product_revision/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2025 Axelspace
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
{
"name": "BOM Product Revision Management",
"summary": "Link product revisions to BOM lines",
"author": "Axelspace, Odoo Community Association (OCA)",
"website": "https://www.axelspace.com",
"license": "AGPL-3",
"category": "Manufacturing",
"version": "16.0.1.0.0",
"depends": ["mrp", "product_revision"],
"data": [
"security/ir.model.access.csv",
"views/mrp_bom_views.xml",
],
"demo": [],
"installable": True,
"auto_install": False,
"application": False,
}
127 changes: 127 additions & 0 deletions bom_product_revision/i18n/ja_JP.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * bom_product_revision
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0-20230701\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-05-06 23:02+0000\n"
"PO-Revision-Date: 2025-05-06 23:02+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: bom_product_revision
#: model:ir.model,name:bom_product_revision.model_mrp_bom
msgid "Bill of Material"
msgstr "部品表"

#. module: bom_product_revision
#: model:ir.model,name:bom_product_revision.model_mrp_bom_line
msgid "Bill of Material Line"
msgstr "部品表明細"

#. module: bom_product_revision
#. odoo-python
#: code:addons/bom_product_revision/models/mrp_bom.py:0
#: code:addons/bom_product_revision/models/mrp_bom_line.py:0
#, python-format
msgid "Inactive Revision Selected"
msgstr "無効なリビジョンが選択されました"

#. module: bom_product_revision
#: model:ir.model.fields,field_description:bom_product_revision.field_mrp_bom__inactive_revision_warning
#: model:ir.model.fields,field_description:bom_product_revision.field_mrp_bom_line__inactive_revision_warning
msgid "Inactive Revision Warning"
msgstr "旧リビジョン使用警告"

#. module: bom_product_revision
#: model:ir.model,name:bom_product_revision.model_product_revision
#: model:ir.model.fields,field_description:bom_product_revision.field_mrp_bom__revision_id
msgid "Product Revision"
msgstr "製品リビジョン"

#. module: bom_product_revision
#: model:ir.model.fields,field_description:bom_product_revision.field_mrp_bom_line__revision_id
msgid "Revision"
msgstr "リビジョン"

#. module: bom_product_revision
#: model:ir.model.fields,field_description:bom_product_revision.field_mrp_bom__revision_active
#: model:ir.model.fields,field_description:bom_product_revision.field_mrp_bom_line__revision_active
msgid "Revision Active"
msgstr "有効なリビジョン"

#. module: bom_product_revision
#: model:ir.model.fields,field_description:bom_product_revision.field_mrp_bom__revision_number
#: model:ir.model.fields,field_description:bom_product_revision.field_mrp_bom_line__revision_number
msgid "Revision Number"
msgstr "リビジョン番号"

#. module: bom_product_revision
#: model:ir.model.fields,help:bom_product_revision.field_mrp_bom__revision_active
#: model:ir.model.fields,help:bom_product_revision.field_mrp_bom_line__revision_active
msgid "Technical field to indicate if the revision is active"
msgstr "リビジョンが有効かどうかを示す技術フィールド"

#. module: bom_product_revision
#: model:ir.model.fields,help:bom_product_revision.field_mrp_bom_line__revision_number
msgid "The revision number of the product in this BOM line"
msgstr "この部品表明細の製品のリビジョン番号"

#. module: bom_product_revision
#: model:ir.model.fields,help:bom_product_revision.field_mrp_bom__revision_number
msgid "The revision number of the product this BOM is for"
msgstr "この部品表用製品のリビジョン番号"

#. module: bom_product_revision
#: model:ir.model.fields,help:bom_product_revision.field_mrp_bom_line__revision_id
msgid "The revision of the product in this BOM line"
msgstr "この部品表明細の製品のリビジョン"

#. module: bom_product_revision
#: model:ir.model.fields,help:bom_product_revision.field_mrp_bom__revision_id
msgid "The revision of the product this BOM is for"
msgstr "この部品表用製品のリビジョン"

#. module: bom_product_revision
#. odoo-python
#: code:addons/bom_product_revision/models/mrp_bom.py:0
#: code:addons/bom_product_revision/models/mrp_bom_line.py:0
#, python-format
msgid ""
"The selected revision '%(revision)s' is not active. This may affect "
"manufacturing processes."
msgstr "選択されたリビジョン '%(revision)s' は無効です。これにより製造プロセスに影響が出る可能性があります。"

#. module: bom_product_revision
#. odoo-python
#: code:addons/bom_product_revision/models/mrp_bom.py:0
#, python-format
msgid ""
"This BOM is using inactive revision \"%(revision)s\". This may affect "
"manufacturing processes."
msgstr "この部品表は無効なリビジョン \"%(revision)s\" を使用しています。これにより製造プロセスに影響が出る可能性があります。"

#. module: bom_product_revision
#. odoo-python
#: code:addons/bom_product_revision/models/mrp_bom_line.py:0
#, python-format
msgid ""
"This BOM line is using inactive revision \"%(revision)s\". This may affect "
"manufacturing processes."
msgstr "この部品表明細は無効なリビジョン \"%(revision)s\" を使用しています。これにより製造プロセスに影響が出る可能性があります。"

#. module: bom_product_revision
#: model:ir.model.fields,help:bom_product_revision.field_mrp_bom_line__inactive_revision_warning
msgid "Warning displayed when the BOM line uses an inactive revision"
msgstr "部品表明細が無効なリビジョンを使用している場合に表示される警告"

#. module: bom_product_revision
#: model:ir.model.fields,help:bom_product_revision.field_mrp_bom__inactive_revision_warning
msgid "Warning displayed when the BOM uses an inactive revision"
msgstr "部品表が無効なリビジョンを使用している場合に表示される警告"
3 changes: 3 additions & 0 deletions bom_product_revision/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import mrp_bom_line
from . import mrp_bom
from . import product_revision
111 changes: 111 additions & 0 deletions bom_product_revision/models/mrp_bom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
from odoo import _, api, fields, models


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

revision_id = fields.Many2one(
"product.revision",
string="Product Revision",
help="The revision of the product this BOM is for",
)
revision_number = fields.Char(
related="revision_id.revision_number",
string="Revision Number",
readonly=True,
store=True,
help="The revision number of the product this BOM is for",
)
inactive_revision_warning = fields.Html(
compute="_compute_inactive_revision_warning",
help="Warning displayed when the BOM uses an inactive revision",
)
revision_active = fields.Boolean(
compute="_compute_revision_active",
help="Technical field to indicate if the revision is active",
store=True,
)

@api.depends("revision_id", "revision_id.active")
def _compute_revision_active(self):
for bom in self:
bom.revision_active = bom.revision_id.active if bom.revision_id else True

@api.depends("revision_id", "revision_id.active")
def _compute_inactive_revision_warning(self):
for bom in self:
if bom.revision_id and not bom.revision_id.active:
warning_message = _(
'This BOM is using inactive revision "%(revision)s". '
"This may affect manufacturing processes.",
revision=bom.revision_id.revision_number,
)
bom.inactive_revision_warning = (
'<div class="alert alert-warning" role="alert">'
f'<strong>{_("Warning")}:</strong> {warning_message}'
"</div>"
)
else:
bom.inactive_revision_warning = False

@api.onchange("product_tmpl_id", "product_id")
def _onchange_product_id(self):
"""When product changes, set the latest revision"""
res = super(MrpBom, self)._onchange_product_id()

# Clear revision when product changes
self.revision_id = False

if self.product_id:
# First check if the product variant has its own revision
if self.product_id.current_revision_id:
self.revision_id = self.product_id.current_revision_id
# If not, fall back to the product template's revision
elif self.product_id.product_tmpl_id.current_revision_id:
self.revision_id = self.product_id.product_tmpl_id.current_revision_id
elif self.product_tmpl_id:
# If only product template is set, use its revision
if self.product_tmpl_id.current_revision_id:
self.revision_id = self.product_tmpl_id.current_revision_id

return res

@api.onchange("revision_id")
def _onchange_revision_id(self):
"""Show warning if selected revision is not active"""
res = {}
if self.revision_id and not self.revision_id.active:
res["warning"] = {
"title": _("Inactive Revision Selected"),
"message": _(
"The selected revision '%(revision)s' is not active. "
"This may affect manufacturing processes.",
revision=self.revision_id.revision_number,
),
}
return res

@api.model_create_multi
def create(self, vals_list):
"""Override create to automatically set the revision_id if available"""
for vals in vals_list:
if not vals.get("revision_id"):
# If product_id is set, use its revision
if vals.get("product_id"):
product = self.env["product.product"].browse(vals["product_id"])
# First check if the product variant has its own revision
if product.current_revision_id:
vals["revision_id"] = product.current_revision_id.id
# If not, fall back to the product template's revision
elif product.product_tmpl_id.current_revision_id:
vals[
"revision_id"
] = product.product_tmpl_id.current_revision_id.id
# If only product_tmpl_id is set, use its revision
elif vals.get("product_tmpl_id"):
product_tmpl = self.env["product.template"].browse(
vals["product_tmpl_id"]
)
if product_tmpl.current_revision_id:
vals["revision_id"] = product_tmpl.current_revision_id.id
return super(MrpBom, self).create(vals_list)
Loading
Loading