diff --git a/mrp_analytic_cost_material/__manifest__.py b/mrp_analytic_cost_material/__manifest__.py index 7e04de5df..3babe9e4e 100644 --- a/mrp_analytic_cost_material/__manifest__.py +++ b/mrp_analytic_cost_material/__manifest__.py @@ -11,7 +11,7 @@ "website": "https://github.com/OCA/manufacture", "license": "AGPL-3", "depends": ["mrp_analytic", "account"], - "data": ["views/account_analytic_line_view.xml"], + "data": ["views/account_analytic_line_view.xml", "views/mrp_production_views.xml"], "maintainer": "dreispt", "development_status": "Alpha", "installable": True, diff --git a/mrp_analytic_cost_material/models/__init__.py b/mrp_analytic_cost_material/models/__init__.py index 35345e57a..b4221a567 100644 --- a/mrp_analytic_cost_material/models/__init__.py +++ b/mrp_analytic_cost_material/models/__init__.py @@ -2,3 +2,4 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from . import account_analytic_line +from . import mrp_production diff --git a/mrp_analytic_cost_material/models/mrp_production.py b/mrp_analytic_cost_material/models/mrp_production.py new file mode 100644 index 000000000..4d3e6471a --- /dev/null +++ b/mrp_analytic_cost_material/models/mrp_production.py @@ -0,0 +1,26 @@ +# Copyright (C) 2020 Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import models + + +class MrpProduction(models.Model): + _inherit = "mrp.production" + + def generate_analytic_line(self): + """Generate Analytic Lines Manually.""" + for order in self: + AccountAnalyticLine = self.env["account.analytic.line"].sudo() + for line in order.move_raw_ids: + line_vals = { + "name": line.product_id.default_code or "", + "account_id": order.analytic_account_id.id or False, + "ref": order.name, + "unit_amount": line.product_uom_qty, + "company_id": order.company_id.id, + "manufacturing_order_id": order.id, + "product_id": line.product_id.id or False, + "stock_move_id": line.raw_material_production_id.id, + } + analytic_line = AccountAnalyticLine.create(line_vals) + analytic_line.on_change_unit_amount() diff --git a/mrp_analytic_cost_material/views/mrp_production_views.xml b/mrp_analytic_cost_material/views/mrp_production_views.xml new file mode 100644 index 000000000..294299a64 --- /dev/null +++ b/mrp_analytic_cost_material/views/mrp_production_views.xml @@ -0,0 +1,18 @@ + + + + custom.mrp.production.form + mrp.production + + + +