Skip to content

Commit

Permalink
[ADD] mrp_bom_line_skip_empty
Browse files Browse the repository at this point in the history
  • Loading branch information
SirAionTech committed Sep 24, 2024
1 parent 1f34d36 commit b964add
Show file tree
Hide file tree
Showing 12 changed files with 610 additions and 0 deletions.
87 changes: 87 additions & 0 deletions mrp_bom_line_skip_empty/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
=======================
Skip empty MRP BoM Line
=======================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:7cfb3a88e42e13f128328dd4a63d5bfccdef0769822be4828842019e65c5b98e
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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%2Fmanufacture-lightgray.png?logo=github
:target: https://github.com/OCA/manufacture/tree/16.0/mrp_bom_line_skip_empty
:alt: OCA/manufacture
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/manufacture-16-0/manufacture-16-0-mrp_bom_line_skip_empty
: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=16.0
:alt: Try me on Runboat

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

Do not create production order lines where quantity to be consumed is 0.

**Table of contents**

.. contents::
:local:

Usage
=====

1. Create a BoM where the quantity for a component is 0
#. Create the production order from the BoM

The created production order does not have the line for the component having quantity 0.

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_line_skip_empty%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.

Credits
=======

Authors
~~~~~~~

* Aion Tech

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-SirAionTech| image:: https://github.com/SirAionTech.png?size=40px
:target: https://github.com/SirAionTech
:alt: SirAionTech

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

|maintainer-SirAionTech|

This module is part of the `OCA/manufacture <https://github.com/OCA/manufacture/tree/16.0/mrp_bom_line_skip_empty>`_ 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_line_skip_empty/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import models
20 changes: 20 additions & 0 deletions mrp_bom_line_skip_empty/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2024 Simone Rubino - Aion Tech
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Skip empty MRP BoM Line",
"summary": "Do not create production order lines "
"where consumed quantity to be consumed is 0.",
"version": "16.0.1.0.0",
"author": "Aion Tech, Odoo Community Association (OCA)",
"maintainers": [
"SirAionTech",
],
"category": "Manufacturing",
"depends": [
"mrp",
],
"website": "https://github.com/OCA/manufacture"
"/tree/16.0/mrp_bom_line_skip_empty",
"license": "AGPL-3",
}
3 changes: 3 additions & 0 deletions mrp_bom_line_skip_empty/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import mrp_production
23 changes: 23 additions & 0 deletions mrp_bom_line_skip_empty/models/mrp_production.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2024 Simone Rubino - Aion Tech
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import models
from odoo.tools import float_is_zero


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

def _remove_empty_move_values(self, moves_values):
"""Remove values that have no quantity."""
clean_moves_raw_values = []
for move_values in moves_values:
product = self.env["product.product"].browse(move_values["product_id"])
quantity = move_values["product_uom_qty"]
if not float_is_zero(quantity, precision_rounding=product.uom_id.rounding):
clean_moves_raw_values.append(move_values)
return clean_moves_raw_values

def _get_moves_raw_values(self):
moves_raw_values = super()._get_moves_raw_values()
return self._remove_empty_move_values(moves_raw_values)
1 change: 1 addition & 0 deletions mrp_bom_line_skip_empty/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Do not create production order lines where quantity to be consumed is 0.
4 changes: 4 additions & 0 deletions mrp_bom_line_skip_empty/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
1. Create a BoM where the quantity for a component is 0
#. Create the production order from the BoM

The created production order does not have the line for the component having quantity 0.
Loading

0 comments on commit b964add

Please sign in to comment.