diff --git a/addons/mrp_account/models/mrp_bom.py b/addons/mrp_account/models/mrp_bom.py index ca2a1029819..1e92a997313 100644 --- a/addons/mrp_account/models/mrp_bom.py +++ b/addons/mrp_account/models/mrp_bom.py @@ -35,7 +35,7 @@ class MrpBom(models.Model): def _onchange_analytic_distribution(self): for record in self: if record.product_id: - record.analytic_distribution = record.env['account.analytic.distribution.model']._get_distribution({ + record.analytic_distribution = record.env['account.analytic.distribution.model'].sudo()._get_distribution({ "product_id": record.product_id.id, "product_categ_id": record.product_id.categ_id.id, "company_id": record.company_id.id, diff --git a/addons/mrp_account/tests/test_mrp_account.py b/addons/mrp_account/tests/test_mrp_account.py index 12760cc30f9..0277e140465 100644 --- a/addons/mrp_account/tests/test_mrp_account.py +++ b/addons/mrp_account/tests/test_mrp_account.py @@ -4,6 +4,7 @@ from odoo.addons.mrp.tests.common import TestMrpCommon from odoo.addons.stock_account.tests.test_account_move import TestAccountMoveStockCommon from odoo.tests import Form, tagged +from odoo.tests.common import new_test_user class TestMrpAccount(TestMrpCommon): @@ -188,6 +189,14 @@ class TestMrpAccount(TestMrpCommon): # 1 table head at 20 + 4 table leg at 15 + 4 bolt at 10 + 10 screw at 10 + 1*20 (extra cost) self.assertEqual(move_value, 141, 'Thing should have the correct price') + def test_stock_user_without_account_permissions_can_create_bom(self): + mrp_manager = new_test_user( + self.env, 'temp_mrp_manager', 'mrp.group_mrp_manager', + ) + + bom_form = Form(self.env['mrp.bom'].with_user(mrp_manager)) + bom_form.product_id = self.dining_table + @tagged("post_install", "-at_install") class TestMrpAccountMove(TestAccountMoveStockCommon):