From d7a9a3b3abc097d54204832ad173fc2de7680d3f Mon Sep 17 00:00:00 2001 From: VoicuStefan2001 Date: Thu, 4 Jul 2024 15:35:48 +0300 Subject: [PATCH] [17.0][UPD] deltatech_mrp_cost --- deltatech_mrp_cost/__manifest__.py | 7 +-- deltatech_mrp_cost/models/__init__.py | 1 + deltatech_mrp_cost/models/mrp_bom.py | 11 ++++ deltatech_mrp_cost/models/mrp_production.py | 27 +++++++++- deltatech_mrp_cost/views/mrp_bom_view.xml | 30 +++++++++++ .../views/mrp_production_templates.xml | 50 +++++++++++-------- 6 files changed, 99 insertions(+), 27 deletions(-) create mode 100644 deltatech_mrp_cost/models/mrp_bom.py create mode 100644 deltatech_mrp_cost/views/mrp_bom_view.xml diff --git a/deltatech_mrp_cost/__manifest__.py b/deltatech_mrp_cost/__manifest__.py index 683e0c556c..d6d129ad8f 100644 --- a/deltatech_mrp_cost/__manifest__.py +++ b/deltatech_mrp_cost/__manifest__.py @@ -4,16 +4,13 @@ { "name": "MRP Cost", "summary": "MRP Cost", - "version": "17.0.2.0.3", + "version": "17.0.2.0.5", "author": "Terrabit, Dorin Hongu", "website": "https://www.terrabit.ro", "category": "Manufacturing", "depends": ["mrp_account"], "license": "OPL-1", - "data": [ - "views/mrp_view.xml", - # "views/mrp_production_templates.xml", #todo: de corectat - ], + "data": ["views/mrp_view.xml", "views/mrp_production_templates.xml", "views/mrp_bom_view.xml"], "images": ["static/description/main_screenshot.png"], "development_status": "Beta", "maintainers": ["dhongu"], diff --git a/deltatech_mrp_cost/models/__init__.py b/deltatech_mrp_cost/models/__init__.py index 9a19185637..0f80126e0f 100644 --- a/deltatech_mrp_cost/models/__init__.py +++ b/deltatech_mrp_cost/models/__init__.py @@ -4,3 +4,4 @@ from . import mrp_production +from . import mrp_bom diff --git a/deltatech_mrp_cost/models/mrp_bom.py b/deltatech_mrp_cost/models/mrp_bom.py new file mode 100644 index 0000000000..65e7d63eab --- /dev/null +++ b/deltatech_mrp_cost/models/mrp_bom.py @@ -0,0 +1,11 @@ +from odoo import fields, models + + +class BOM(models.Model): + _inherit = "mrp.bom" + + overhead_amount = fields.Float(string="Overhead", default="0.0") + duration = fields.Float(string="Duration") + utility_consumption = fields.Float(string="Utility consumption", help="Utilities consumption per hour") + net_salary_rate = fields.Float(string="Net Salary Rate") + salary_contributions = fields.Float(string="Salary Contributions") diff --git a/deltatech_mrp_cost/models/mrp_production.py b/deltatech_mrp_cost/models/mrp_production.py index 3bc62f8bba..54c9c01043 100644 --- a/deltatech_mrp_cost/models/mrp_production.py +++ b/deltatech_mrp_cost/models/mrp_production.py @@ -3,7 +3,7 @@ # See README.rst file on addons root folder for license details -from odoo import fields, models +from odoo import api, fields, models class MrpProduction(models.Model): @@ -56,3 +56,28 @@ def _cal_price(self, consumed_moves): self.extra_cost = costs / self.product_qty return super()._cal_price(consumed_moves) + + @api.model + def create(self, vals_list): + bom_id = vals_list.get("bom_id") + if bom_id: + bom = self.env["mrp.bom"].browse(bom_id) + vals_list["overhead_amount"] = bom.overhead_amount + vals_list["utility_consumption"] = bom.utility_consumption + vals_list["net_salary_rate"] = bom.net_salary_rate + vals_list["salary_contributions"] = bom.salary_contributions + vals_list["duration"] = vals_list["product_qty"] / bom.product_qty * bom.duration + + return super().create(vals_list) + + # def action_confirm(self): + # # Call the original method + # res = super(MrpProduction, self).action_confirm() + # + # if self.bom_id: + # self.overhead_amount = self.product_qty / self.bom_id.product_qty * self.bom_id.overhead_amount + # self.utility_consumption = self.product_qty / self.bom_id.product_qty * self.bom_id.utility_consumption + # self.net_salary_rate = self.product_qty / self.bom_id.product_qty * self.bom_id.net_salary_rate + # self.salary_contributions = self.product_qty / self.bom_id.product_qty * self.bom_id.salary_contributions + # self.duration = self.product_qty / self.bom_id.product_qty * self.bom_id.duration + # return res diff --git a/deltatech_mrp_cost/views/mrp_bom_view.xml b/deltatech_mrp_cost/views/mrp_bom_view.xml new file mode 100644 index 0000000000..bc23bdca5a --- /dev/null +++ b/deltatech_mrp_cost/views/mrp_bom_view.xml @@ -0,0 +1,30 @@ + + + + deltatech.mrp.bom.form + mrp.bom + form + + + + + + + + + + + + + + + + + + + diff --git a/deltatech_mrp_cost/views/mrp_production_templates.xml b/deltatech_mrp_cost/views/mrp_production_templates.xml index c36eb109da..8957f56678 100644 --- a/deltatech_mrp_cost/views/mrp_production_templates.xml +++ b/deltatech_mrp_cost/views/mrp_production_templates.xml @@ -4,8 +4,9 @@
- Date:
- + Date: +
+
@@ -13,23 +14,27 @@
- Overhead Amount:
+ Overhead Amount: +
-
- Utility Consumption:
+
+ Utility Consumption: +
-
- Net Salary Rate:
+
+ Net Salary Rate: +
- Salary Contributions:
+ Salary Contributions: +
-
+
@@ -66,12 +71,12 @@ - + - + @@ -87,7 +92,11 @@ - + + +