-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[16.0][IMP] fermente_mrp compute product stock rule
- Loading branch information
1 parent
bd27075
commit b0ab216
Showing
9 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 models |
This file contains 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 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,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (C) 2025 - Today: GRAP (http://www.grap.coop) | ||
@author: Quentin DUPONT ([email protected]) | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
--> | ||
<odoo noupdate="1"> | ||
|
||
<record id="stock.route_warehouse0_mto" model="stock.route"> | ||
<field name="active" eval="True" /> | ||
</record> | ||
|
||
</odoo> |
This file contains 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 product_template |
This file contains 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,24 @@ | ||
# Copyright (C) 2025 - Today: GRAP (http://www.grap.coop) | ||
# @author: Quentin DUPONT ([email protected]) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
|
||
from odoo import models | ||
|
||
|
||
class ProductTemplate(models.Model): | ||
_inherit = "product.template" | ||
|
||
""" | ||
Note 1 : j'ai hesité à enlever la route si pas de BoM mais effet de bord : | ||
Si tu coches "Manufacture" et que tu as pas de BoM encore, ça le décoche. Donc naze. | ||
""" | ||
|
||
def _compute_bom_count(self): | ||
super()._compute_bom_count() | ||
manufacture_route = self.env.ref("mrp.route_warehouse0_manufacture").id | ||
for product in self.filtered(lambda x: x.bom_count != 0): | ||
product.route_ids = [ | ||
(4, manufacture_route), | ||
] | ||
return True |
This file contains 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 |
---|---|---|
@@ -1 +1,2 @@ | ||
* Sylvain LE GAL (https://www.twitter.com/legalsylvain) | ||
* Quentin DUPONT ([email protected]) |
This file contains 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 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 test_product_template |
This file contains 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,43 @@ | ||
# Copyright (C) 2025 - Today: GRAP (http://www.grap.coop) | ||
# @author: Quentin DUPONT ([email protected]) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo.tests.common import TransactionCase | ||
|
||
|
||
class TestProductTemplate(TransactionCase): | ||
def setUp(self): | ||
super().setUp() | ||
self.manufacture_route = self.env.ref("mrp.route_warehouse0_manufacture") | ||
|
||
self.product_test = self.env["product.template"].create( | ||
{ | ||
"name": "Product Test", | ||
} | ||
) | ||
|
||
self.bom = self.env["mrp.bom"].create( | ||
{ | ||
"product_tmpl_id": self.product_test.id, | ||
"product_qty": 1.0, | ||
} | ||
) | ||
|
||
def test_01_compute_bom_count_with_bom(self): | ||
self.product_test._compute_bom_count() | ||
|
||
self.assertIn( | ||
self.manufacture_route, | ||
self.product_test.route_ids, | ||
"Manufacturing route should have been added.", | ||
) | ||
|
||
def test_02_compute_bom_count_without_bom(self): | ||
self.bom.unlink() | ||
self.product_test._compute_bom_count() | ||
|
||
self.assertNotIn( | ||
self.manufacture_route, | ||
self.product_test.route_ids, | ||
"Manufacturing route should have been deleted.", | ||
) |