[FIX] mrp_account: missing employee cost when calculate bom cost

Adapt community to make it possible to add employee cost when calculate
bom cost.

closes odoo/odoo#105645

X-original-commit: a239802249b2af2cc3fc2b3bb9fdfd0a408d887a
Related: odoo/enterprise#33898
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Yuchen Huang (yhu) <yhu@odoo.com>
This commit is contained in:
yhu-odoo
2022-11-14 13:01:57 +01:00
parent 29789fb732
commit ba4e24b932
5 changed files with 19 additions and 4 deletions
+1
View File
@@ -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
+12
View File
@@ -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
+1 -1
View File
@@ -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):
+3 -1
View File
@@ -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")
@@ -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."""