Skip to content

Commit

Permalink
[MIG] mrp_bom_attribute_match: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mymage committed Feb 9, 2024
1 parent 3d199d9 commit 5ee00e3
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 35 deletions.
23 changes: 13 additions & 10 deletions mrp_bom_attribute_match/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
BOM Attribute Match
===================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:f598ece9b32319e94b8b593ab4fedb6065d0965d3725a767a2ba630893da7d4d
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
Expand All @@ -14,16 +17,16 @@ BOM Attribute Match
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github
:target: https://github.com/OCA/manufacture/tree/15.0/mrp_bom_attribute_match
:target: https://github.com/OCA/manufacture/tree/16.0/mrp_bom_attribute_match
:alt: OCA/manufacture
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/manufacture-15-0/manufacture-15-0-mrp_bom_attribute_match
:target: https://translation.odoo-community.org/projects/manufacture-16-0/manufacture-16-0-mrp_bom_attribute_match
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/129/15.0
:alt: Try me on Runbot
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/manufacture&target_branch=16.0
:alt: Try me on Runboat

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

This module addresses the BoM case where the product to manufacture has one attribute with tens or hundreds of values (usually attribute "color", eg: "Configurable Desk" can be produced in 900 different colors).

Expand Down Expand Up @@ -98,8 +101,8 @@ 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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/manufacture/issues/new?body=module:%20mrp_bom_attribute_match%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
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_attribute_match%0Aversion:%2016.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.

Expand Down Expand Up @@ -136,6 +139,6 @@ 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/15.0/mrp_bom_attribute_match>`_ project on GitHub.
This module is part of the `OCA/manufacture <https://github.com/OCA/manufacture/tree/16.0/mrp_bom_attribute_match>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion mrp_bom_attribute_match/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "BOM Attribute Match",
"version": "15.0.1.0.0",
"version": "16.0.1.0.0",
"category": "Manufacturing",
"author": "Ilyas, Ooops, Odoo Community Association (OCA)",
"summary": "Dynamic BOM component based on product attribute",
Expand Down
42 changes: 22 additions & 20 deletions mrp_bom_attribute_match/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>BOM Attribute Match</title>
<style type="text/css">

/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Copyright: This stylesheet has been placed in the public domain.

Default cascading style sheet for the HTML output of Docutils.

See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/

Expand Down Expand Up @@ -366,8 +366,10 @@ <h1 class="title">BOM Attribute Match</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:f598ece9b32319e94b8b593ab4fedb6065d0965d3725a767a2ba630893da7d4d
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/manufacture/tree/15.0/mrp_bom_attribute_match"><img alt="OCA/manufacture" src="https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/manufacture-15-0/manufacture-15-0-mrp_bom_attribute_match"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/129/15.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/manufacture/tree/16.0/mrp_bom_attribute_match"><img alt="OCA/manufacture" src="https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/manufacture-16-0/manufacture-16-0-mrp_bom_attribute_match"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/manufacture&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module addresses the BoM case where the product to manufacture has one attribute with tens or hundreds of values (usually attribute “color”, eg: “Configurable Desk” can be produced in 900 different colors).</p>
<p>Creating a dynamic BoM currently requires adding one BoM line for each attribute value to match component variant with attribute value (eg: component “Desk board (Green)” to be applied to variant “Green”).</p>
<p>This has 3 downsides:</p>
Expand Down Expand Up @@ -400,18 +402,18 @@ <h1 class="title">BOM Attribute Match</h1>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#usage" id="id1">Usage</a></li>
<li><a class="reference internal" href="#bug-tracker" id="id2">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id3">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id4">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id5">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id6">Maintainers</a></li>
<li><a class="reference internal" href="#usage" id="toc-entry-1">Usage</a></li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-2">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-3">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-4">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-5">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-6">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#id1">Usage</a></h1>
<h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
<p>Using this module you can have dynamic components of a BOM.
It will allow you to have only 1 line in the BOM if you have hundreds of attribute
values for manufacturing product and hundreds of attributes values of component (material).</p>
Expand All @@ -435,24 +437,24 @@ <h1><a class="toc-backref" href="#id1">Usage</a></h1>
And a values of this attribute of a manufacturing product should be available for a component.</p>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#id2">Bug Tracker</a></h1>
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/manufacture/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/manufacture/issues/new?body=module:%20mrp_bom_attribute_match%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/manufacture/issues/new?body=module:%20mrp_bom_attribute_match%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#id3">Credits</a></h1>
<h1><a class="toc-backref" href="#toc-entry-3">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#id4">Authors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-4">Authors</a></h2>
<ul class="simple">
<li>Ilyas</li>
<li>Ooops</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#id5">Contributors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<ul class="simple">
<li>Ooops404 &lt;<a class="reference external" href="https://ooops404.com">https://ooops404.com</a>&gt;<ul>
<li>Ilyas</li>
Expand All @@ -465,13 +467,13 @@ <h2><a class="toc-backref" href="#id5">Contributors</a></h2>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#id6">Maintainers</a></h2>
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/manufacture/tree/15.0/mrp_bom_attribute_match">OCA/manufacture</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/manufacture/tree/16.0/mrp_bom_attribute_match">OCA/manufacture</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
23 changes: 22 additions & 1 deletion mrp_bom_attribute_match/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ def _create_products(self):
"route_ids": [(6, 0, [route_manufacture])],
}
)
self.p4 = self.env["product.template"].create(
{
"name": "P4",
"type": "product",
"route_ids": [(6, 0, [route_manufacture])],
}
)
self.product_9 = self.env["product.product"].create(
{
"name": "Paper",
Expand Down Expand Up @@ -92,10 +99,24 @@ def _create_products(self):

def _create_boms(self):
mrp_bom_form = Form(self.env["mrp.bom"])

category = self.env["uom.category"].search([])[0]

self.env["uom.uom"].create(
{
"name": "Bigger UoM of my category",
"factor_inv": 42,
"uom_type": "bigger",
"rounding": 0.5,
"category_id": category.id,
}
)
mrp_bom_form.bom_line_ids.product_uom_id = self.env["uom.uom"].search([])[0].id
mrp_bom_form.product_tmpl_id = self.product_sword
with mrp_bom_form.bom_line_ids.new() as line_form:
line_form.component_template_id = self.product_plastic
line_form.product_qty = 1
mrp_bom_form._values["product_uom_id"] = self.env["uom.uom"].search([])[0]
self.bom_id = mrp_bom_form.save()

mrp_bom_form = Form(self.env["mrp.bom"])
Expand Down Expand Up @@ -129,6 +150,6 @@ def _create_boms(self):
mrp_bom_form = Form(self.env["mrp.bom"])
mrp_bom_form.product_tmpl_id = self.p3
with mrp_bom_form.bom_line_ids.new() as line_form:
line_form.product_id = self.p1.product_variant_ids[0]
line_form.product_id = self.p4.product_variant_ids[0]
line_form.product_qty = 1
self.p3_bom_id = mrp_bom_form.save()
11 changes: 8 additions & 3 deletions mrp_bom_attribute_match/tests/test_mrp_bom_attribute_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
class TestMrpAttachmentMgmt(TestMrpAttachmentMgmtBase):
@classmethod
def setUpClass(cls):
cls.product_id = 1
super().setUpClass()

def test_bom_1(self):
Expand Down Expand Up @@ -73,8 +74,8 @@ def test_bom_2(self):
def test_manufacturing_order_1(self):
mo_form = Form(self.env["mrp.production"])
mo_form.product_id = self.product_sword.product_variant_ids.filtered(
lambda x: x.display_name == "Plastic Sword (Cyan)"
)
lambda x: x.name == "Plastic Sword"
)[0]
mo_form.bom_id = self.bom_id
mo_form.product_qty = 1
self.mo_sword = mo_form.save()
Expand All @@ -90,7 +91,7 @@ def test_manufacturing_order_2(self):
self.plastic_attrs.value_ids = [(3, self.plastic_attrs.value_ids[0].id, 0)]
mo_form = Form(self.env["mrp.production"])
mo_form.product_id = self.product_sword.product_variant_ids.filtered(
lambda x: x.display_name == "Plastic Sword (Cyan)"
lambda x: x.display_name == "Plastic Sword"
)
mo_form.bom_id = self.bom_id
mo_form.product_qty = 1
Expand All @@ -102,6 +103,10 @@ def test_manufacturing_order_3(self):
self.product_sword.attribute_line_ids = [(5, 0, 0)]
mo_form = Form(self.env["mrp.production"])
mo_form.product_id = self.product_sword.product_variant_ids[0]
# added to have product_uom_id.roundig > 0
product_uom_id = self.env["uom.uom"].search([])[0].id
for bom_line in self.bom_id.bom_line_ids:
bom_line.product_uom_id = product_uom_id
# Component skipped
mo_form.bom_id = self.bom_id
mo_form.product_qty = 1
Expand Down
6 changes: 6 additions & 0 deletions mrp_bom_attribute_match/views/mrp_bom_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
</attribute>
<attribute name="force_save">"1"</attribute>
</xpath>
<xpath
expr="//field[@name='bom_line_ids']//field[@name='product_uom_id']"
position="after"
>
<field name="product_uom_id" invisible="1" />
</xpath>
</field>
</record>
</odoo>

0 comments on commit 5ee00e3

Please sign in to comment.