Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][MIG] mrp_production_deconstruction: Migration to 16.0 #367

Closed
Closed
29 changes: 29 additions & 0 deletions mrp_production_deconstruction/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3

==============================
MPR Production Deconstruction
==============================

Deconstruction in production order. If is a deconstruction, it changes the source location and the destination location.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues
<https://github.com/avanzosc/mrp-addons/issues>`_. In case of trouble,
please check there if your issue has already been reported. If you spotted
it first, help us smash it by providing detailed and welcomed feedback.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Contributors
------------

* Berezi Amubieta <[email protected]>
* Alfredo de la Fuente <[email protected]>
* Ana Juaristi <[email protected]>
1 change: 1 addition & 0 deletions mrp_production_deconstruction/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
18 changes: 18 additions & 0 deletions mrp_production_deconstruction/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2022 Berezi Amubieta - AvanzOSC
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
"name": "MRP Production Deconstruction",
"version": "16.0.1.0.0",
"author": "Avanzosc",
"website": "https://github.com/avanzosc/mrp-addons",
"category": "MRP",
"depends": [
"mrp",
],
"data": [
"views/mrp_production_view.xml",
"views/mrp_bom_view.xml",
],
"license": "AGPL-3",
"installable": True,
}
110 changes: 110 additions & 0 deletions mrp_production_deconstruction/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mrp_production_deconstruction
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-11-15 15:22+0000\n"
"PO-Revision-Date: 2023-11-15 15:22+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: mrp_production_deconstruction
#: model:ir.model,name:mrp_production_deconstruction.model_mrp_bom
msgid "Bill of Material"
msgstr "Lista de materiales"

#. module: mrp_production_deconstruction
#: model_terms:ir.ui.view,arch_db:mrp_production_deconstruction.view_mrp_bom_filter
#: model_terms:ir.ui.view,arch_db:mrp_production_deconstruction.view_mrp_production_filter
msgid "Deconstruction"
msgstr "Deconstrucción"

#. module: mrp_production_deconstruction
#: model:ir.model.fields,field_description:mrp_production_deconstruction.field_mrp_bom__display_name
#: model:ir.model.fields,field_description:mrp_production_deconstruction.field_mrp_production__display_name
#: model:ir.model.fields,field_description:mrp_production_deconstruction.field_stock_move_line__display_name
msgid "Display Name"
msgstr "Mostrar nombre"

#. module: mrp_production_deconstruction
#: model:ir.model.fields,field_description:mrp_production_deconstruction.field_stock_move_line__location_id
msgid "From"
msgstr "Desde"

#. module: mrp_production_deconstruction
#: model:ir.model.fields,field_description:mrp_production_deconstruction.field_mrp_bom__id
#: model:ir.model.fields,field_description:mrp_production_deconstruction.field_mrp_production__id
#: model:ir.model.fields,field_description:mrp_production_deconstruction.field_stock_move_line__id
msgid "ID"
msgstr "Identificador"

#. module: mrp_production_deconstruction
#: model:ir.model.fields,field_description:mrp_production_deconstruction.field_mrp_bom__is_deconstruction
#: model:ir.model.fields,field_description:mrp_production_deconstruction.field_mrp_production__is_deconstruction
msgid "Is Deconstruction?"
msgstr "¿Es una deconstrucción?"

#. module: mrp_production_deconstruction
#: model:ir.model.fields,field_description:mrp_production_deconstruction.field_mrp_bom____last_update
#: model:ir.model.fields,field_description:mrp_production_deconstruction.field_mrp_production____last_update
#: model:ir.model.fields,field_description:mrp_production_deconstruction.field_stock_move_line____last_update
msgid "Last Modified on"
msgstr "Última modificación el"

#. module: mrp_production_deconstruction
#: model_terms:ir.ui.view,arch_db:mrp_production_deconstruction.view_mrp_production_filter
msgid "Last Month"
msgstr "Último mes"

#. module: mrp_production_deconstruction
#: model_terms:ir.ui.view,arch_db:mrp_production_deconstruction.view_mrp_production_filter
msgid "Last Week"
msgstr "Última semana"

#. module: mrp_production_deconstruction
#: model_terms:ir.ui.view,arch_db:mrp_production_deconstruction.view_mrp_production_filter
msgid "Last Year"
msgstr "Último año"

#. module: mrp_production_deconstruction
#: model:ir.model.fields,field_description:mrp_production_deconstruction.field_mrp_production__move_line_ids
#: model_terms:ir.ui.view,arch_db:mrp_production_deconstruction.mrp_production_form_view
msgid "Move Lines"
msgstr "Operaciones detalladas"

#. module: mrp_production_deconstruction
#: model:ir.model,name:mrp_production_deconstruction.model_stock_move_line
msgid "Product Moves (Stock Move Line)"
msgstr "Movimientos de Producto (Stock Move Line)"

#. module: mrp_production_deconstruction
#: model:ir.model,name:mrp_production_deconstruction.model_mrp_production
msgid "Production Order"
msgstr "Orden de producción"

#. module: mrp_production_deconstruction
#: model:ir.model.fields,field_description:mrp_production_deconstruction.field_stock_move_line__location_dest_id
msgid "To"
msgstr "Hasta"

#. module: mrp_production_deconstruction
#: model_terms:ir.ui.view,arch_db:mrp_production_deconstruction.view_mrp_production_filter
msgid "Today"
msgstr "Hoy"

#. module: mrp_production_deconstruction
#: model_terms:ir.ui.view,arch_db:mrp_production_deconstruction.mrp_production_form_view
msgid "Total Reserved"
msgstr "Total reservado"

#. module: mrp_production_deconstruction
#: model_terms:ir.ui.view,arch_db:mrp_production_deconstruction.view_mrp_production_filter
msgid "Yesterday"
msgstr "Ayer"
110 changes: 110 additions & 0 deletions mrp_production_deconstruction/i18n/mrp_production_deconstruction.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mrp_production_deconstruction
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-11-15 15:22+0000\n"
"PO-Revision-Date: 2023-11-15 15:22+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: mrp_production_deconstruction
#: model:ir.model,name:mrp_production_deconstruction.model_mrp_bom
msgid "Bill of Material"
msgstr ""

#. module: mrp_production_deconstruction
#: model_terms:ir.ui.view,arch_db:mrp_production_deconstruction.view_mrp_bom_filter
#: model_terms:ir.ui.view,arch_db:mrp_production_deconstruction.view_mrp_production_filter
msgid "Deconstruction"
msgstr ""

#. module: mrp_production_deconstruction
#: model:ir.model.fields,field_description:mrp_production_deconstruction.field_mrp_bom__display_name
#: model:ir.model.fields,field_description:mrp_production_deconstruction.field_mrp_production__display_name
#: model:ir.model.fields,field_description:mrp_production_deconstruction.field_stock_move_line__display_name
msgid "Display Name"
msgstr ""

#. module: mrp_production_deconstruction
#: model:ir.model.fields,field_description:mrp_production_deconstruction.field_stock_move_line__location_id
msgid "From"
msgstr ""

#. module: mrp_production_deconstruction
#: model:ir.model.fields,field_description:mrp_production_deconstruction.field_mrp_bom__id
#: model:ir.model.fields,field_description:mrp_production_deconstruction.field_mrp_production__id
#: model:ir.model.fields,field_description:mrp_production_deconstruction.field_stock_move_line__id
msgid "ID"
msgstr ""

#. module: mrp_production_deconstruction
#: model:ir.model.fields,field_description:mrp_production_deconstruction.field_mrp_bom__is_deconstruction
#: model:ir.model.fields,field_description:mrp_production_deconstruction.field_mrp_production__is_deconstruction
msgid "Is Deconstruction?"
msgstr ""

#. module: mrp_production_deconstruction
#: model:ir.model.fields,field_description:mrp_production_deconstruction.field_mrp_bom____last_update
#: model:ir.model.fields,field_description:mrp_production_deconstruction.field_mrp_production____last_update
#: model:ir.model.fields,field_description:mrp_production_deconstruction.field_stock_move_line____last_update
msgid "Last Modified on"
msgstr ""

#. module: mrp_production_deconstruction
#: model_terms:ir.ui.view,arch_db:mrp_production_deconstruction.view_mrp_production_filter
msgid "Last Month"
msgstr ""

#. module: mrp_production_deconstruction
#: model_terms:ir.ui.view,arch_db:mrp_production_deconstruction.view_mrp_production_filter
msgid "Last Week"
msgstr ""

#. module: mrp_production_deconstruction
#: model_terms:ir.ui.view,arch_db:mrp_production_deconstruction.view_mrp_production_filter
msgid "Last Year"
msgstr ""

#. module: mrp_production_deconstruction
#: model:ir.model.fields,field_description:mrp_production_deconstruction.field_mrp_production__move_line_ids
#: model_terms:ir.ui.view,arch_db:mrp_production_deconstruction.mrp_production_form_view
msgid "Move Lines"
msgstr ""

#. module: mrp_production_deconstruction
#: model:ir.model,name:mrp_production_deconstruction.model_stock_move_line
msgid "Product Moves (Stock Move Line)"
msgstr ""

#. module: mrp_production_deconstruction
#: model:ir.model,name:mrp_production_deconstruction.model_mrp_production
msgid "Production Order"
msgstr ""

#. module: mrp_production_deconstruction
#: model:ir.model.fields,field_description:mrp_production_deconstruction.field_stock_move_line__location_dest_id
msgid "To"
msgstr ""

#. module: mrp_production_deconstruction
#: model_terms:ir.ui.view,arch_db:mrp_production_deconstruction.view_mrp_production_filter
msgid "Today"
msgstr ""

#. module: mrp_production_deconstruction
#: model_terms:ir.ui.view,arch_db:mrp_production_deconstruction.mrp_production_form_view
msgid "Total Reserved"
msgstr ""

#. module: mrp_production_deconstruction
#: model_terms:ir.ui.view,arch_db:mrp_production_deconstruction.view_mrp_production_filter
msgid "Yesterday"
msgstr ""
3 changes: 3 additions & 0 deletions mrp_production_deconstruction/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import mrp_bom
from . import mrp_production
from . import stock_move_line
9 changes: 9 additions & 0 deletions mrp_production_deconstruction/models/mrp_bom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright 2022 Berezi Amubieta - AvanzOSC
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import fields, models


class MrpBom(models.Model):
_inherit = "mrp.bom"

is_deconstruction = fields.Boolean(string="Is Deconstruction?", default=False)
92 changes: 92 additions & 0 deletions mrp_production_deconstruction/models/mrp_production.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Copyright 2022 Berezi Amubieta - AvanzOSC
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models


class MrpProduction(models.Model):
_inherit = "mrp.production"

is_deconstruction = fields.Boolean(
string="Is Deconstruction?", related="bom_id.is_deconstruction", store=True
)
move_line_ids = fields.One2many(
string="Move Lines",
comodel_name="stock.move.line",
inverse_name="production_id",
domain=lambda self: [
("location_dest_id", "in", self.production_location_id.ids)
],
)
finished_move_line_ids = fields.One2many(
compute=False,
inverse_name="production_id",
domain=lambda self: [
("location_id", "in", self.production_location_id.ids),
("location_dest_id", "in", self.location_dest_id.ids),
],
)

@api.depends("product_id", "company_id", "is_deconstruction")
def _compute_production_location(self):
result = super()._compute_production_location()
for production in self:
if production.is_deconstruction:
production.production_location_id = (
production.picking_type_id.default_location_src_id.id
) or (False)
return result

def write(self, vals):
res = super().write(vals)
if "move_finished_ids" in vals:
for line in self:
if line.is_deconstruction and line.move_finished_ids:
for move in line.move_finished_ids:
move.location_id = line.production_location_id.id
move.location_dest_id = line.location_src_id.id
return res

def _check_is_deconstruction(self):
for production in self:
if (
production.bom_id
and (production.is_deconstruction) is True
and (production.move_raw_ids)
):
origin = production.picking_type_id.default_location_src_id
if origin.usage != "internal" and (
production.production_location_id.usage
) == ("internal"):
origin = production.production_location_id
dest = production.move_raw_ids.location_dest_id
if dest.usage == "production":
production.write(
{
"location_dest_id": dest.id,
"location_src_id": dest.id,
"production_location_id": origin.id,
}
)
for move in production.move_raw_ids:
move.write(
{"location_id": dest.id, "location_dest_id": origin.id}
)
for line in move.move_line_ids:
line.write(
{"location_id": dest.id, "location_dest_id": origin.id}
)

def action_confirm(self):
self._check_is_deconstruction()
return super().action_confirm()

def button_mark_done(self):
result = super().button_mark_done()
for production in self:
if production.is_deconstruction is True:
origin = production.finished_move_line_ids.location_id
dest = production.finished_move_line_ids.location_dest_id
production.finished_move_line_ids.write(
{"location_id": dest.id, "location_dest_id": origin.id}
)
return result
Loading
Loading