Skip to content

Commit

Permalink
Merge pull request #1536 from VoicuStefan2001/17.0
Browse files Browse the repository at this point in the history
[17.0][UPD] deltatech_mrp_cost
  • Loading branch information
VoicuStefan2001 authored Jul 4, 2024
2 parents 270d11e + d7a9a3b commit 0bc6e8b
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 27 deletions.
7 changes: 2 additions & 5 deletions deltatech_mrp_cost/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
1 change: 1 addition & 0 deletions deltatech_mrp_cost/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@


from . import mrp_production
from . import mrp_bom
11 changes: 11 additions & 0 deletions deltatech_mrp_cost/models/mrp_bom.py
Original file line number Diff line number Diff line change
@@ -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")
27 changes: 26 additions & 1 deletion deltatech_mrp_cost/models/mrp_production.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
30 changes: 30 additions & 0 deletions deltatech_mrp_cost/views/mrp_bom_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" ?>
<odoo>
<record id="bom_form_view" model="ir.ui.view">
<field name="name">deltatech.mrp.bom.form</field>
<field name="model">mrp.bom</field>
<field name="type">form</field>
<field name="inherit_id" ref="mrp.mrp_bom_form_view" />
<field name="arch" type="xml">
<xpath expr="//notebook" position="inside">
<page string="Costs">
<group>
<group>
<field name="overhead_amount" />
<field name="utility_consumption" />
<field name="net_salary_rate" />
<field name="salary_contributions" />
</group>
<group>
<label for="duration" />
<div>
<field name="duration" widget="float_time" class="oe_inline" />
hours
</div>
</group>
</group>
</page>
</xpath>
</field>
</record>
</odoo>
50 changes: 29 additions & 21 deletions deltatech_mrp_cost/views/mrp_production_templates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,37 @@

<xpath expr="//div[@t-if='o.origin']" position="before">
<div class="col-3">
<strong>Date:</strong><br />
<span t-field="o.date_planned_start" t-options='{"widget": "date"}' />
<strong>Date:</strong>
<br />
<span t-field="o.date_start" t-options='{"widget": "date"}' />
</div>
</xpath>


<xpath expr="//div[@t-if='o.workorder_ids']" position="before">
<div class="row mt32 mb32">
<div class="col-3" t-if="o.overhead_amount">
<strong>Overhead Amount:</strong><br />
<strong>Overhead Amount:</strong>
<br />
<span t-field="o.overhead_amount" />
</div>
<div class="col-3" t-if="o.utility_consumption">
<strong>Utility Consumption:</strong><br />
<div class="col-3" t-if="o.utility_consumption">
<strong>Utility Consumption:</strong>
<br />
<span t-field="o.utility_consumption" />
</div>
<div class="col-3" t-if="o.net_salary_rate">
<strong>Net Salary Rate:</strong><br />
<div class="col-3" t-if="o.net_salary_rate">
<strong>Net Salary Rate:</strong>
<br />
<span t-field="o.net_salary_rate" />
</div>
<div class="col-3" t-if="o.salary_contributions">
<strong>Salary Contributions:</strong><br />
<strong>Salary Contributions:</strong>
<br />
<span t-field="o.salary_contributions" />
</div>
</div>
<br />
<br />
</xpath>


Expand Down Expand Up @@ -66,12 +71,12 @@
<span t-field="line.product_uom.name" groups="uom.group_uom" />
</td>
<td class="text-right">
<span t-field="line.quantity_done" />
<span t-field="line.quantity" />
<span t-field="line.product_uom.name" groups="uom.group_uom" />
</td>
<t t-set="value" t-value="-sum(line.mapped('stock_valuation_layer_ids.value'))" />
<td class="text-right">
<span t-if="line.quantity_done">
<span t-if="line.quantity">
<span t-field="line.price_unit" />
</span>
<span t-else="">
Expand All @@ -87,7 +92,11 @@
</table>
</xpath>

<xpath expr="//table[@t-if='o.move_raw_ids']//thead/tr" position="inside">
</template>

<template id="report_production_components" inherit_id="mrp.report_mrp_production_components">

<xpath expr="//th[@t-if='has_product_barcode']" position="after">
<th class="text-right">
<strong>Effective Quantity</strong>
</th>
Expand All @@ -99,26 +108,25 @@
</th>
</xpath>

<xpath expr="//table[@t-if='o.move_raw_ids']//tbody//tr" position="inside">
<td class="text-right">
<span t-field="raw_line.quantity_done" />
<xpath expr="//table[@class='table table-sm']//tbody//tr" position="inside">
<td t-attf-class="text-end">
<span t-field="raw_line.quantity" />
<span t-field="raw_line.product_uom.name" groups="uom.group_uom" />
</td>
<t t-set="value" t-value="-sum(raw_line.mapped('stock_valuation_layer_ids.value'))" />
<td class="text-right">
<span t-if="raw_line.quantity_done">
<t t-set="price_unit" t-value="value/raw_line.quantity_done" />
<span t-esc="price_unit" t-options='{"widget": "float", "precision": 2}' />
<td t-attf-class="text-end">
<span t-if="raw_line.quantity">
<t t-set="price_unit" t-value="value/raw_line.quantity" />
<span t-esc="price_unit" t-options='{"widget": "float", "precision": 2}' />
</span>
<span t-else="">
<span t-field="raw_line.product_id.sudo().standard_price" />
</span>

</td>
<td class="text-right">
<td t-attf-class="text-end">
<span t-esc="value" t-options='{"widget": "float", "precision": 2}' />
</td>
</xpath>

</template>
</odoo>

0 comments on commit 0bc6e8b

Please sign in to comment.