Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[17.0] [MIG] product_configurator_mrp_component #123

Open
wants to merge 18 commits into
base: 17.0
Choose a base branch
from
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
105 changes: 105 additions & 0 deletions product_configurator_mrp_component/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
=============================================
Product Configurator Manufacturing Components
=============================================

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

.. |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-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%2Fproduct--configurator-lightgray.png?logo=github
:target: https://github.com/OCA/product-configurator/tree/17.0/product_configurator_mrp_component
:alt: OCA/product-configurator
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/product-configurator-17-0/product-configurator-17-0-product_configurator_mrp_component
: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/product-configurator&target_branch=17.0
:alt: Try me on Runboat

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

Adds the ability to have configurable products as components on Bill of
Materials.

**Table of contents**

.. contents::
:local:

Configuration
=============

1. Setup the parent product to contain all attributes/values as the
configuration components.
2. Create a BoM for the parent product, and add the configurable
components and their qty to the BoM, in the Configurable Components
tab.
3. Only configurable products that have all their attribute values in
the parent product will be able to be added to the BoM.

Usage
=====

- When the parent product is configured, the system will look for the
first BoM for that product and cycle through the configurable
components.
- If a product variant doesn't exist for the configurable component
then one will be created with the matching values in the config
wizard.
- The parent product BoM will then be modified with a new bom line(s)
and configuration set(s) for the new configurable component variants.
- The new parent product variant will be created if one doesn't exist
and it's BoM will contain the new configurable components lines.

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/product-configurator/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/product-configurator/issues/new?body=module:%20product_configurator_mrp_component%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
-------

* Pledra

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.

.. |maintainer-PCatinean| image:: https://github.com/PCatinean.png?size=40px
:target: https://github.com/PCatinean
:alt: PCatinean

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-PCatinean|

This module is part of the `OCA/product-configurator <https://github.com/OCA/product-configurator/tree/17.0/product_configurator_mrp_component>`_ 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 product_configurator_mrp_component/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
21 changes: 21 additions & 0 deletions product_configurator_mrp_component/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright (C) 2022-Today Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Product Configurator Manufacturing Components",
"version": "17.0.1.0.0",
"category": "Manufacturing",
"summary": "BOM Support for configurable products",
"author": "Pledra, Odoo Community Association (OCA)",
"license": "AGPL-3",
"website": "https://github.com/OCA/product-configurator",
"depends": ["product_configurator_mrp"],
"data": [
"security/ir.model.access.csv",
"views/mrp_bom.xml",
],
"installable": True,
"auto_install": False,
"development_status": "Beta",
"maintainers": ["PCatinean"],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_configurator_mrp_component
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \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: product_configurator_mrp_component
#: model:ir.model.fields,field_description:product_configurator_mrp_component.field_mrp_bom_line__product_template_attribute_value_ids
msgid "Attribute Values"
msgstr ""

#. module: product_configurator_mrp_component
#: model:ir.model.fields,field_description:product_configurator_mrp_component.field_mrp_bom__available_config_components
#: model:ir.model.fields,field_description:product_configurator_mrp_component.field_mrp_bom_line_config__available_config_components
msgid "Available Config Components"
msgstr ""

#. module: product_configurator_mrp_component
#: model:ir.model,name:product_configurator_mrp_component.model_mrp_bom_line_config
msgid "BOM Line Configuration"
msgstr ""

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

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

#. module: product_configurator_mrp_component
#: model:ir.model.fields,field_description:product_configurator_mrp_component.field_mrp_bom_line_config__bom_id
msgid "BoM"
msgstr ""

#. module: product_configurator_mrp_component
#: model:ir.model.fields,field_description:product_configurator_mrp_component.field_mrp_bom_line__config_ok
msgid "Can be Configured"
msgstr ""

#. module: product_configurator_mrp_component
#: model_terms:ir.ui.view,arch_db:product_configurator_mrp_component.mrp_bom_filter_inherit
msgid "Configurable Component"
msgstr ""

#. module: product_configurator_mrp_component
#: model:ir.model.fields,field_description:product_configurator_mrp_component.field_mrp_bom__bom_line_config_ids
#: model_terms:ir.ui.view,arch_db:product_configurator_mrp_component.mrp_bom_configurable_components_inherit
msgid "Configurable Components"
msgstr ""

#. module: product_configurator_mrp_component
#: model:ir.model.fields,field_description:product_configurator_mrp_component.field_mrp_bom_line_config__product_tmpl_id
msgid "Configurable Product"
msgstr ""

#. module: product_configurator_mrp_component
#: model_terms:ir.ui.view,arch_db:product_configurator_mrp_component.mrp_bom_configurable_components_inherit
msgid "Configure Components"
msgstr ""

#. module: product_configurator_mrp_component
#: model:ir.model.fields,field_description:product_configurator_mrp_component.field_mrp_bom_line_config__create_uid
msgid "Created by"
msgstr ""

#. module: product_configurator_mrp_component
#: model:ir.model.fields,field_description:product_configurator_mrp_component.field_mrp_bom_line_config__create_date
msgid "Created on"
msgstr ""

#. module: product_configurator_mrp_component
#: model:ir.model.fields,field_description:product_configurator_mrp_component.field_mrp_bom__display_name
#: model:ir.model.fields,field_description:product_configurator_mrp_component.field_mrp_bom_line__display_name
#: model:ir.model.fields,field_description:product_configurator_mrp_component.field_mrp_bom_line_config__display_name
#: model:ir.model.fields,field_description:product_configurator_mrp_component.field_product_config_session__display_name
msgid "Display Name"
msgstr ""

#. module: product_configurator_mrp_component
#: model:ir.model.fields,field_description:product_configurator_mrp_component.field_mrp_bom__id
#: model:ir.model.fields,field_description:product_configurator_mrp_component.field_mrp_bom_line__id
#: model:ir.model.fields,field_description:product_configurator_mrp_component.field_mrp_bom_line_config__id
#: model:ir.model.fields,field_description:product_configurator_mrp_component.field_product_config_session__id
msgid "ID"
msgstr ""

#. module: product_configurator_mrp_component
#: model:ir.model.fields,field_description:product_configurator_mrp_component.field_mrp_bom____last_update
#: model:ir.model.fields,field_description:product_configurator_mrp_component.field_mrp_bom_line____last_update
#: model:ir.model.fields,field_description:product_configurator_mrp_component.field_mrp_bom_line_config____last_update
#: model:ir.model.fields,field_description:product_configurator_mrp_component.field_product_config_session____last_update
msgid "Last Modified on"
msgstr ""

#. module: product_configurator_mrp_component
#: model:ir.model.fields,field_description:product_configurator_mrp_component.field_mrp_bom_line_config__write_uid
msgid "Last Updated by"
msgstr ""

#. module: product_configurator_mrp_component
#: model:ir.model.fields,field_description:product_configurator_mrp_component.field_mrp_bom_line_config__write_date
msgid "Last Updated on"
msgstr ""

#. module: product_configurator_mrp_component
#: model:ir.model,name:product_configurator_mrp_component.model_product_config_session
msgid "Product Config Session"
msgstr ""

#. module: product_configurator_mrp_component
#: model:ir.model.fields,field_description:product_configurator_mrp_component.field_mrp_bom_line_config__product_uom_id
msgid "Product Unit of Measure"
msgstr ""

#. module: product_configurator_mrp_component
#: model_terms:ir.ui.view,arch_db:product_configurator_mrp_component.mrp_bom_configurable_components_inherit
msgid "Product has been set to configurable."
msgstr ""

#. module: product_configurator_mrp_component
#: model:ir.model.fields,field_description:product_configurator_mrp_component.field_mrp_bom_line_config__product_qty
msgid "Quantity"
msgstr ""
3 changes: 3 additions & 0 deletions product_configurator_mrp_component/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import mrp_bom_line_config
from . import mrp_bom
from . import product_config
67 changes: 67 additions & 0 deletions product_configurator_mrp_component/models/mrp_bom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Copyright (C) 2022-Today Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


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

bom_line_config_ids = fields.One2many(
"mrp.bom.line.config", "bom_id", string="Configurable Components"
)
available_config_components = fields.Many2many(
"product.template",
compute="_compute_available_config_components",
store=True,
)

@api.depends("bom_line_config_ids", "product_tmpl_id")
def _compute_available_config_components(self):
"""Compute list of products available for configurable components"""
for bom in self:
if bom.config_ok and not bom.product_id:
bom.available_config_components = False
products = self.env["product.template"].search(
[
("config_ok", "=", True),
("id", "!=", bom.product_tmpl_id.id),
(
"id",
"!=",
bom.bom_line_config_ids.mapped("product_tmpl_id").ids,
),
]
)
for prod in products:
prod_attrs = prod.mapped("attribute_line_ids.attribute_id")
bom_tmpl_attrs = bom.product_tmpl_id.mapped(
"attribute_line_ids.attribute_id"
)
# First compare that bom prod contains all attr that conf comp has
if all(attr in bom_tmpl_attrs for attr in prod_attrs):
for attribute_line in prod.attribute_line_ids:
prod_vals = prod.mapped(
"attribute_line_ids.value_ids"
).filtered(
lambda m, attribute_line=attribute_line: m.attribute_id
== attribute_line.attribute_id
)
bom_tmpl_values = bom.product_tmpl_id.mapped(
"attribute_line_ids.value_ids"
).filtered(
lambda m, attribute_line=attribute_line: m.attribute_id
== attribute_line.attribute_id
)
# If bom prod has all vals that conf comp has then add it
if all(att_val in bom_tmpl_values for att_val in prod_vals):
bom.available_config_components = [(4, prod.id)]


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

config_ok = fields.Boolean(related="product_id.config_ok")
product_template_attribute_value_ids = fields.Many2many(
related="product_id.product_template_attribute_value_ids"
)
38 changes: 38 additions & 0 deletions product_configurator_mrp_component/models/mrp_bom_line_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright (C) 2022-Today Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class MRPBoMLineConfig(models.Model):
_name = "mrp.bom.line.config"
_description = "BOM Line Configuration"

def _get_default_product_uom_id(self):
return self.env["uom.uom"].search([], limit=1, order="id").id

bom_id = fields.Many2one(
"mrp.bom",
string="BoM",
required=True,
)
product_tmpl_id = fields.Many2one(
"product.template",
string="Configurable Product",
required=True,
)
product_qty = fields.Float(
"Quantity",
default=1.0,
required=True,
)
product_uom_id = fields.Many2one(
"uom.uom",
default=_get_default_product_uom_id,
string="Product Unit of Measure",
required=True,
)
available_config_components = fields.Many2many(
"product.template",
related="bom_id.available_config_components",
)
Loading
Loading