diff --git a/addons/mrp_account/models/__init__.py b/addons/mrp_account/models/__init__.py index 33ff5e20d93..90c1c962e22 100644 --- a/addons/mrp_account/models/__init__.py +++ b/addons/mrp_account/models/__init__.py @@ -5,6 +5,7 @@ from . import mrp_bom from . import mrp_workcenter from . import mrp_workorder from . import mrp_production +from . import mrp_routing from . import product from . import stock_move from . import stock_rule diff --git a/addons/mrp_account/models/mrp_routing.py b/addons/mrp_account/models/mrp_routing.py new file mode 100644 index 00000000000..f36d70eac02 --- /dev/null +++ b/addons/mrp_account/models/mrp_routing.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import models + + +class MrpRoutingWorkcenter(models.Model): + _inherit = 'mrp.routing.workcenter' + + def _total_cost_per_hour(self): + self.ensure_one() + return self.workcenter_id.costs_hour diff --git a/addons/mrp_account/models/product.py b/addons/mrp_account/models/product.py index 06471524d8c..e10272b02c9 100644 --- a/addons/mrp_account/models/product.py +++ b/addons/mrp_account/models/product.py @@ -80,7 +80,7 @@ class ProductProduct(models.Model): opt.workcenter_id.time_start + opt.workcenter_id.time_stop + opt.time_cycle * 100 / opt.workcenter_id.time_efficiency) - total += (duration_expected / 60) * opt.workcenter_id.costs_hour + total += (duration_expected / 60) * opt._total_cost_per_hour() for line in bom.bom_line_ids: if line._skip_bom_line(self): diff --git a/addons/mrp_account/tests/test_bom_price.py b/addons/mrp_account/tests/test_bom_price.py index 8ea43a4ac4a..5d407b0d635 100644 --- a/addons/mrp_account/tests/test_bom_price.py +++ b/addons/mrp_account/tests/test_bom_price.py @@ -6,7 +6,7 @@ from odoo.tests import common, Form from odoo.tools.float_utils import float_round, float_compare -class TestBomPrice(common.TransactionCase): +class TestBomPriceCommon(common.TransactionCase): @classmethod def _create_product(cls, name, price): @@ -101,6 +101,8 @@ class TestBomPrice(common.TransactionCase): line.product_qty = 57 cls.bom_2 = bom_form2.save() + +class TestBomPrice(TestBomPriceCommon): def test_00_compute_price(self): """Test multi-level BoM cost""" self.assertEqual(self.dining_table.standard_price, 1000, "Initial price of the Product should be 1000") diff --git a/addons/mrp_subcontracting_account/tests/test_subcontracting_account.py b/addons/mrp_subcontracting_account/tests/test_subcontracting_account.py index cf7955b474c..7e62091595e 100644 --- a/addons/mrp_subcontracting_account/tests/test_subcontracting_account.py +++ b/addons/mrp_subcontracting_account/tests/test_subcontracting_account.py @@ -6,7 +6,7 @@ from odoo.tests.common import Form from odoo.tools.float_utils import float_round, float_compare from odoo.addons.mrp_subcontracting.tests.common import TestMrpSubcontractingCommon -from odoo.addons.mrp_account.tests.test_bom_price import TestBomPrice +from odoo.addons.mrp_account.tests.test_bom_price import TestBomPriceCommon class TestAccountSubcontractingFlows(TestMrpSubcontractingCommon): def test_subcontracting_account_flow_1(self): @@ -212,7 +212,7 @@ class TestAccountSubcontractingFlows(TestMrpSubcontractingCommon): ]) -class TestBomPriceSubcontracting(TestBomPrice): +class TestBomPriceSubcontracting(TestBomPriceCommon): def test_01_compute_price_subcontracting_cost(self): """Test calculation of bom cost with subcontracting."""