Skip to content

Commit

Permalink
[14.0][IMP] custom_mrp_descarga: Add new fields in production.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tu Nombre authored and Berezi committed Oct 22, 2024
1 parent 1139ce0 commit 8a3b2fe
Show file tree
Hide file tree
Showing 9 changed files with 204 additions and 12 deletions.
1 change: 1 addition & 0 deletions custom_mrp_descarga/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"data/ir_cron_data.xml",
"views/saca_line_view.xml",
"views/mrp_production_view.xml",
"views/mrp_workorder_view.xml",
"views/stock_production_lot_view.xml",
"views/stock_quant_view.xml",
"views/mrp_bom_view.xml",
Expand Down
44 changes: 42 additions & 2 deletions custom_mrp_descarga/i18n/custom_mrp_descarga.pot
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-09-11 12:55+0000\n"
"PO-Revision-Date: 2024-09-11 12:55+0000\n"
"POT-Creation-Date: 2024-10-22 09:12+0000\n"
"PO-Revision-Date: 2024-10-22 09:12+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
Expand Down Expand Up @@ -260,6 +260,7 @@ msgstr ""
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_account_analytic_line__display_name
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_bom__display_name
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production__display_name
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_workorder__display_name
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_product_template__display_name
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_project_task__display_name
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_report_mrp_production_quartering_summary_xlsx__display_name
Expand All @@ -278,6 +279,11 @@ msgstr ""
msgid "Don't produce the header product"
msgstr ""

#. module: custom_mrp_descarga
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_stock_move_line__qty_done
msgid "Done"
msgstr ""

#. module: custom_mrp_descarga
#: model_terms:ir.ui.view,arch_db:custom_mrp_descarga.stock_move_line_view_search
msgid "Done bigger than 0"
Expand Down Expand Up @@ -369,6 +375,7 @@ msgstr ""
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_account_analytic_line__id
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_bom__id
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production__id
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_workorder__id
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_product_template__id
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_project_task__id
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_report_mrp_production_quartering_summary_xlsx__id
Expand Down Expand Up @@ -400,6 +407,11 @@ msgstr ""
msgid "Input Products"
msgstr ""

#. module: custom_mrp_descarga
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production__speed_consume_unit
msgid "Input Unit/Hour"
msgstr ""

#. module: custom_mrp_descarga
#: model_terms:ir.ui.view,arch_db:custom_mrp_descarga.mrp_bom_form_view
#: model_terms:ir.ui.view,arch_db:custom_mrp_descarga.mrp_production_form_view
Expand Down Expand Up @@ -461,6 +473,7 @@ msgstr ""
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_account_analytic_line____last_update
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_bom____last_update
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production____last_update
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_workorder____last_update
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_product_template____last_update
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_project_task____last_update
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_report_mrp_production_quartering_summary_xlsx____last_update
Expand Down Expand Up @@ -628,6 +641,11 @@ msgstr ""
msgid "Peso medio"
msgstr ""

#. module: custom_mrp_descarga
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production__speed_consume_qty
msgid "Produced Kg/Hour"
msgstr ""

#. module: custom_mrp_descarga
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production__produced_qty
msgid "Produced Qty"
Expand Down Expand Up @@ -852,6 +870,11 @@ msgstr ""
msgid "The product of the lot does not match with the product of the line."
msgstr ""

#. module: custom_mrp_descarga
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production__timesheet_ids
msgid "Timesheet"
msgstr ""

#. module: custom_mrp_descarga
#: model_terms:ir.ui.view,arch_db:custom_mrp_descarga.view_mrp_production_filter
msgid "Today"
Expand Down Expand Up @@ -883,6 +906,13 @@ msgstr ""
msgid "Total Done"
msgstr ""

#. module: custom_mrp_descarga
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production__total_duration
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_workorder__total_duration
#: model_terms:ir.ui.view,arch_db:custom_mrp_descarga.mrp_production_workorder_tree_editable_view
msgid "Total Duration"
msgstr ""

#. module: custom_mrp_descarga
#: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0
#: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0
Expand Down Expand Up @@ -983,11 +1013,21 @@ msgstr ""
msgid "Vehicle"
msgstr ""

#. module: custom_mrp_descarga
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_workorder__waiting_duration
msgid "Waiting"
msgstr ""

#. module: custom_mrp_descarga
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production__waiting_time
msgid "Waiting Time"
msgstr ""

#. module: custom_mrp_descarga
#: model:ir.model,name:custom_mrp_descarga.model_mrp_workorder
msgid "Work Order"
msgstr ""

#. module: custom_mrp_descarga
#: model:ir.ui.menu,name:custom_mrp_descarga.menu_view_workcenter_cost_despiece
msgid "Workcenter Cost"
Expand Down
44 changes: 42 additions & 2 deletions custom_mrp_descarga/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-09-11 12:55+0000\n"
"PO-Revision-Date: 2024-09-11 12:55+0000\n"
"POT-Creation-Date: 2024-10-22 09:12+0000\n"
"PO-Revision-Date: 2024-10-22 09:12+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
Expand Down Expand Up @@ -262,6 +262,7 @@ msgstr "% diferencia"
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_account_analytic_line__display_name
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_bom__display_name
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production__display_name
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_workorder__display_name
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_product_template__display_name
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_project_task__display_name
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_report_mrp_production_quartering_summary_xlsx__display_name
Expand All @@ -280,6 +281,11 @@ msgstr "Mostrar nombre"
msgid "Don't produce the header product"
msgstr "No producir producto de cabecera"

#. module: custom_mrp_descarga
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_stock_move_line__qty_done
msgid "Done"
msgstr "Hecho"

#. module: custom_mrp_descarga
#: model_terms:ir.ui.view,arch_db:custom_mrp_descarga.stock_move_line_view_search
msgid "Done bigger than 0"
Expand Down Expand Up @@ -371,6 +377,7 @@ msgstr "Galllinas"
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_account_analytic_line__id
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_bom__id
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production__id
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_workorder__id
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_product_template__id
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_project_task__id
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_report_mrp_production_quartering_summary_xlsx__id
Expand Down Expand Up @@ -402,6 +409,11 @@ msgstr "Incubadora"
msgid "Input Products"
msgstr "Productos de entrada"

#. module: custom_mrp_descarga
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production__speed_consume_unit
msgid "Input Unit/Hour"
msgstr "Unidades entradas/hora"

#. module: custom_mrp_descarga
#: model_terms:ir.ui.view,arch_db:custom_mrp_descarga.mrp_bom_form_view
#: model_terms:ir.ui.view,arch_db:custom_mrp_descarga.mrp_production_form_view
Expand Down Expand Up @@ -463,6 +475,7 @@ msgstr ""
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_account_analytic_line____last_update
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_bom____last_update
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production____last_update
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_workorder____last_update
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_product_template____last_update
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_project_task____last_update
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_report_mrp_production_quartering_summary_xlsx____last_update
Expand Down Expand Up @@ -630,6 +643,11 @@ msgstr "Rendimiento"
msgid "Peso medio"
msgstr ""

#. module: custom_mrp_descarga
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production__speed_consume_qty
msgid "Produced Kg/Hour"
msgstr "Kg producidos/hora"

#. module: custom_mrp_descarga
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production__produced_qty
msgid "Produced Qty"
Expand Down Expand Up @@ -854,6 +872,11 @@ msgstr "El lote saliente debe coincidir con alguno de la entrada."
msgid "The product of the lot does not match with the product of the line."
msgstr "El producto del lote no coincide con el producto de la línea."

#. module: custom_mrp_descarga
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production__timesheet_ids
msgid "Timesheet"
msgstr "Tiempos"

#. module: custom_mrp_descarga
#: model_terms:ir.ui.view,arch_db:custom_mrp_descarga.view_mrp_production_filter
msgid "Today"
Expand Down Expand Up @@ -885,6 +908,13 @@ msgstr "Total envases"
msgid "Total Done"
msgstr "Total hecho"

#. module: custom_mrp_descarga
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production__total_duration
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_workorder__total_duration
#: model_terms:ir.ui.view,arch_db:custom_mrp_descarga.mrp_production_workorder_tree_editable_view
msgid "Total Duration"
msgstr "Duración total"

#. module: custom_mrp_descarga
#: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0
#: code:addons/custom_mrp_descarga/report/mrp_production_quartering_summary_xlsx.py:0
Expand Down Expand Up @@ -985,11 +1015,21 @@ msgstr "Fecha descarga"
msgid "Vehicle"
msgstr "Vehículo"

#. module: custom_mrp_descarga
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_workorder__waiting_duration
msgid "Waiting"
msgstr "Espera"

#. module: custom_mrp_descarga
#: model:ir.model.fields,field_description:custom_mrp_descarga.field_mrp_production__waiting_time
msgid "Waiting Time"
msgstr "Tiempo de espera"

#. module: custom_mrp_descarga
#: model:ir.model,name:custom_mrp_descarga.model_mrp_workorder
msgid "Work Order"
msgstr "Orden de trabajo"

#. module: custom_mrp_descarga
#: model:ir.ui.menu,name:custom_mrp_descarga.menu_view_workcenter_cost_despiece
msgid "Workcenter Cost"
Expand Down
1 change: 1 addition & 0 deletions custom_mrp_descarga/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
from . import stock_move_line
from . import mrp_bom
from . import stock_inventory_line
from . import mrp_workorder
44 changes: 38 additions & 6 deletions custom_mrp_descarga/models/mrp_production.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,44 @@ def _default_production_date(self):
related="bom_id.recalculate_cost",
store=True,
)
total_duration = fields.Float(compute="_compute_total_duration", store=True)
speed_consume_qty = fields.Float(
string="Produced Kg/Hour", compute="_compute_speed_consume_qty", store=True
)
speed_consume_unit = fields.Float(
string="Input Unit/Hour",
compute="_compute_speed_consume_unit",
store=True,
)
timesheet_ids = fields.One2many(
comodel_name="account.analytic.line", related="saca_line_id.timesheet_ids"
)

@api.depends("total_duration", "total_unit")
def _compute_speed_consume_unit(self):
for production in self:
speed_consume_unit = 0
if production.total_duration != 0:
speed_consume_unit = (
production.total_unit / production.total_duration * 60
)
production.speed_consume_unit = speed_consume_unit

@api.depends("total_duration", "produced_qty")
def _compute_speed_consume_qty(self):
for production in self:
speed_produced_qty = 0
if production.total_duration != 0:
speed_produced_qty = (
production.produced_qty / production.total_duration * 60
)
production.speed_consume_qty = speed_produced_qty

@api.depends("workorder_ids", "workorder_ids.duration")
def _compute_total_duration(self):
for production in self:
duration = sum(production.workorder_ids.mapped("duration"))
production.total_duration = duration

@api.depends("move_line_ids.percentage")
def _compute_rto_percentage(self):
Expand Down Expand Up @@ -269,12 +307,6 @@ def _compute_asphyxiation_units(self):
)
line.asphyxiation_units = asphyxiation_units

def _compute_classified_ids(self):
for line in self:
cond = [("production_id", "=", line.id), ("classified", "=", True)]
classified = self.env["account.analytic.line"].search(cond)
line.clasified_ids = [(6, 0, classified.ids)]

@api.depends("produced_qty", "consume_qty")
def _compute_qty_difference(self):
for production in self:
Expand Down
29 changes: 29 additions & 0 deletions custom_mrp_descarga/models/mrp_workorder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright 2024 Berezi Amubieta - AvanzOSC
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from datetime import timedelta

from odoo import api, fields, models


class MrpWorkorder(models.Model):
_inherit = "mrp.workorder"

waiting_duration = fields.Float(
string="Waiting", compute="_compute_waiting_duration", store=True
)
total_duration = fields.Float(compute="_compute_total_duration", store=True)

@api.depends("duration", "waiting_duration")
def _compute_total_duration(self):
for workorder in self:
workorder.total_duration = workorder.duration + workorder.waiting_duration

@api.depends("date_start", "date_finished", "duration")
def _compute_waiting_duration(self):
for workorder in self:
waiting = 0
if workorder.date_start and workorder.date_finished:
dif = workorder.date_finished - workorder.date_start
dif = dif.total_seconds() / timedelta(minutes=1).total_seconds()
waiting = dif - workorder.duration
workorder.waiting_duration = waiting
2 changes: 1 addition & 1 deletion custom_mrp_descarga/models/stock_inventory_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def onchange_cost(self):
and (c.location_id == self.location_id)
and c.picking_id
)
if entry_line:
if entry_line and sum(entry_line.mapped("qty_done")) != 0:
dev_line_amount = sum(dev_line.mapped("amount")) or 0
dev_line_qty = sum(dev_line.mapped("qty_done")) or 0
self.cost = (sum(entry_line.mapped("amount")) - dev_line_amount) / (
Expand Down
32 changes: 31 additions & 1 deletion custom_mrp_descarga/views/mrp_production_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,11 @@
/>
<field
name="staff"
attrs="{'invisible':[('saca_id', '=', False)], 'readonly': [('state', 'in', ('cancel', 'done'))]}"
attrs="{'readonly': [('state', 'in', ('cancel', 'done'))]}"
/>
<field name="total_duration" invisible="1" />
<field name="speed_consume_qty" />
<field name="speed_consume_unit" />
</field>
<field name="production_date" position="attributes">
<attribute name="invisible">1</attribute>
Expand Down Expand Up @@ -642,6 +645,33 @@
<field name="company_id" invisible="1" />
</tree>
</field>
<field name="timesheet_ids">
<tree editable="bottom">
<field name="sequence" widget="handle" />
<field name="date" optional="show" force_save="1" />
<field name="date_end" optional="show" force_save="1" />
<field name="project_id" optional="show" readonly="1" />
<field name="task_id" optional="show" readonly="1" />
<field
name="time_start"
optional="show"
widget="float_time"
/>
<field
name="time_stop"
optional="show"
widget="float_time"
/>
<field
name="unit_amount"
optional="show"
widget="float_time"
sum="Amount Duration"
/>
<field name="speed" />
<field name="company_id" invisible="1" />
</tree>
</field>
</page>
</notebook>
</field>
Expand Down
Loading

0 comments on commit 8a3b2fe

Please sign in to comment.