-
-
Notifications
You must be signed in to change notification settings - Fork 552
[MIG] mrp_multi_level_consume_safety_stock: Migration to 18.0
#1682
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
Open
Camille0907
wants to merge
4
commits into
OCA:18.0
Choose a base branch
from
camptocamp:18.0-mig-mrp_multi_level_consume_safety_stock
base: 18.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+776
−5
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
ca6b697
[ADD] mrp_multi_level_consume_safety_stock
gurneyalex 9197240
[IMP] : pre-commit auto fixes
Camille0907 7a95804
[MIG] mrp_multi_level_consume_safety_stock: Migration to 18.0
Camille0907 8fc61e3
[FIX] `mrp_multi_level` : Ensure the safety stock is rebuilt as soon …
Camille0907 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| ==================================== | ||
| MRP Multi Level Consume Safety Stock | ||
| ==================================== | ||
|
|
||
| .. | ||
| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
| !! This file is generated by oca-gen-addon-readme !! | ||
| !! changes will be overwritten. !! | ||
| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
| !! source digest: sha256:ad2f169fa6d149c34adaf973e45bd63b040820bcf4909aaf906ed0be7b0cb8c1 | ||
| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
|
||
| .. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png | ||
| :target: https://odoo-community.org/page/development-status | ||
| :alt: Production/Stable | ||
| .. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png | ||
| :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html | ||
| :alt: License: LGPL-3 | ||
| .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github | ||
| :target: https://github.com/OCA/manufacture/tree/18.0/mrp_multi_level_consume_safety_stock | ||
| :alt: OCA/manufacture | ||
| .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
| :target: https://translation.odoo-community.org/projects/manufacture-18-0/manufacture-18-0-mrp_multi_level_consume_safety_stock | ||
| :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=18.0 | ||
| :alt: Try me on Runboat | ||
|
|
||
| |badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
|
||
| This module complements the mrp_multi_level module by allowing to set a | ||
| date on the mrp.area records until which no attempt to rebuild safety | ||
| stock will be attempted: the safety stock will be used, if the running | ||
| stock get below zero, then a resupply will be created to bring back the | ||
| stock to zero. | ||
|
|
||
| The idea is that your area may be under tension at a given moment (maybe | ||
| some workers are off, maybe there is high demand from customers) and you | ||
| can barely keep up with the demand. In this case, you can set Safety | ||
| stock rebuild lead date to a date in the future at which you anticipate | ||
| that the situation will have been fixed. | ||
|
|
||
| **Table of contents** | ||
|
|
||
| .. contents:: | ||
| :local: | ||
|
|
||
| Usage | ||
| ===== | ||
|
|
||
| When this module is installed, you get an additional parameter on the | ||
| mrp.area records: | ||
|
|
||
| - Safety stock lead date | ||
|
|
||
| Until that date, the MRP Multi Level planner will consume the safety | ||
| stock without attempting to rebuild it, and only resupply if the | ||
| forecasted stock goes below zero. | ||
|
|
||
| If the date is in the paste, nothing special happens. | ||
|
|
||
| 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_multi_level_consume_safety_stock%0Aversion:%2018.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 | ||
| ------- | ||
|
|
||
| * Camptocamp | ||
|
|
||
| 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-gurneyalex| image:: https://github.com/gurneyalex.png?size=40px | ||
| :target: https://github.com/gurneyalex | ||
| :alt: gurneyalex | ||
|
|
||
| Current `maintainer <https://odoo-community.org/page/maintainer-role>`__: | ||
|
|
||
| |maintainer-gurneyalex| | ||
|
|
||
| This module is part of the `OCA/manufacture <https://github.com/OCA/manufacture/tree/18.0/mrp_multi_level_consume_safety_stock>`_ project on GitHub. | ||
|
|
||
| You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| from . import models | ||
| from . import wizards |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # Copyright 2023 Camptocamp (https://www.camptocamp.com) | ||
| # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). | ||
|
|
||
| { | ||
| "name": "MRP Multi Level Consume Safety Stock", | ||
| "version": "18.0.1.0.0", | ||
| "development_status": "Production/Stable", | ||
| "license": "LGPL-3", | ||
| "author": "Camptocamp, Odoo Community Association (OCA)", | ||
| "maintainers": ["gurneyalex"], | ||
| "summary": "MRP scheduler: use safety stock during stress periods", | ||
| "website": "https://github.com/OCA/manufacture", | ||
| "category": "Manufacturing", | ||
| "depends": ["mrp_multi_level"], | ||
| "data": ["views/mrp_area_views.xml"], | ||
| "installable": True, | ||
| "application": True, | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| from . import mrp_area, product_mrp_area |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # Copyright 2023 Camptocamp (https://www.camptocamp.com) | ||
| # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). | ||
|
|
||
| from odoo import fields, models | ||
|
|
||
|
|
||
| class MrpArea(models.Model): | ||
| _inherit = "mrp.area" | ||
|
|
||
| safety_stock_target_date = fields.Date( | ||
| string="Safety stock lead date", | ||
| help="We will start rebuilding safety stock on that date", | ||
| default=fields.Date.today, | ||
| ) |
26 changes: 26 additions & 0 deletions
26
mrp_multi_level_consume_safety_stock/models/product_mrp_area.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| # Copyright 2023 Camptocamp (https://www.camptocamp.com) | ||
| # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). | ||
| from dateutil.relativedelta import relativedelta | ||
|
|
||
| from odoo import api, fields, models | ||
|
|
||
|
|
||
| class ProductMrpArea(models.Model): | ||
| _inherit = "product.mrp.area" | ||
|
|
||
| safety_stock_target_date = fields.Date( | ||
| string="Safety stock lead date", | ||
| compute="_compute_safety_stock_target_date", | ||
| help="The date when we can restart supplying for this product", | ||
| ) | ||
|
|
||
| @api.depends( | ||
| "mrp_lead_time", | ||
| "mrp_area_id.safety_stock_target_date", | ||
| ) | ||
| def _compute_safety_stock_target_date(self): | ||
| today = fields.Date.context_today(self) | ||
| for rec in self: | ||
| delta = relativedelta(days=rec.mrp_lead_time) | ||
| area_target_date = rec.mrp_area_id.safety_stock_target_date or today | ||
| rec.safety_stock_target_date = max(today, area_target_date + delta) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| [build-system] | ||
| requires = ["whool"] | ||
| build-backend = "whool.buildapi" |
11 changes: 11 additions & 0 deletions
11
mrp_multi_level_consume_safety_stock/readme/DESCRIPTION.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| This module complements the mrp_multi_level module by allowing to set a | ||
| date on the mrp.area records until which no attempt to rebuild safety | ||
| stock will be attempted: the safety stock will be used, if the running | ||
| stock get below zero, then a resupply will be created to bring back the | ||
| stock to zero. | ||
|
|
||
| The idea is that your area may be under tension at a given moment (maybe | ||
| some workers are off, maybe there is high demand from customers) and you | ||
| can barely keep up with the demand. In this case, you can set Safety | ||
| stock rebuild lead date to a date in the future at which you anticipate | ||
| that the situation will have been fixed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| When this module is installed, you get an additional parameter on the | ||
| mrp.area records: | ||
|
|
||
| - Safety stock lead date | ||
|
|
||
| Until that date, the MRP Multi Level planner will consume the safety | ||
| stock without attempting to rebuild it, and only resupply if the | ||
| forecasted stock goes below zero. | ||
|
|
||
| If the date is in the paste, nothing special happens. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Camille0907 This is outside of the migration, can you add a test case for this?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the commit message, a test case already covers this, but was previously failing (TBC)