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

[15.0][ADD] mrp_sn_single_rule #76

Draft
wants to merge 1 commit into
base: 15.0
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions mrp_sn_single_rule/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
16 changes: 16 additions & 0 deletions mrp_sn_single_rule/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# © 2024 Solvos Consultoría Informática (<http://www.solvos.es>)
# License LGPL-3 - See https://www.gnu.org/licenses/lgpl-3.0.html

{
"name": "MRP S/N product rule for single creation",
"summary": """
Ensures that a MO is created with only one product when a manufacture stock
rule is launched and involve a S/N tracked product
""",
"author": "Solvos",
"license": "LGPL-3",
"version": "15.0.1.0.0",
"category": "Manufacturing",
"website": "https://github.com/solvosci/slv-manufacture",
"depends": ["mrp"],
}
1 change: 1 addition & 0 deletions mrp_sn_single_rule/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import stock_rule
39 changes: 39 additions & 0 deletions mrp_sn_single_rule/models/stock_rule.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# © 2024 Solvos Consultoría Informática (<http://www.solvos.es>)
# License LGPL-3 - See https://www.gnu.org/licenses/lgpl-3.0.html

from odoo import api, models


class StockRule(models.Model):
_inherit = "stock.rule"

@api.model
def _run_manufacture(self, procurements):
"""
Those procurements that belong to s/n products are splitted into single
qty ones, so MOs that require only 1.0 qty will be created
"""
new_procurements = []
proc_obj = self.env["procurement.group"]
for procurement, rule in procurements:
if (
procurement.product_id.tracking == "serial"
and procurement.product_qty > 1.0
):
for k in range(0, int(procurement.product_qty)):
new_procurements.append((
proc_obj.Procurement(
procurement.product_id,
1.0,
procurement.product_uom,
procurement.location_id,
procurement.name,
procurement.origin,
procurement.company_id,
procurement.values
),
rule
))
else:
new_procurements.append((procurement, rule))
return super()._run_manufacture(new_procurements)
1 change: 1 addition & 0 deletions mrp_sn_single_rule/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* David Alonso <[email protected]>
2 changes: 2 additions & 0 deletions mrp_sn_single_rule/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Ensures that a MO is created with only one product when a manufacture stock
rule is launched and involve a S/N tracked product.
Binary file added mrp_sn_single_rule/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.