Skip to content

Commit

Permalink
Merge PR #14 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Mar 26, 2024
2 parents 3da7845 + 2847093 commit a85a4d4
Show file tree
Hide file tree
Showing 27 changed files with 1,316 additions and 0 deletions.
1 change: 1 addition & 0 deletions setup/stock_request_mrp/odoo/addons/stock_request_mrp
6 changes: 6 additions & 0 deletions setup/stock_request_mrp/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
90 changes: 90 additions & 0 deletions stock_request_mrp/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
=================
Stock Request MRP
=================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:7c15f1dddaca7ee3743051948f8eed6abfc12717561c243510016782a5e9af16
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--request-lightgray.png?logo=github
:target: https://github.com/OCA/stock-logistics-request/tree/16.0/stock_request_mrp
:alt: OCA/stock-logistics-request
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/stock-logistics-request-16-0/stock-logistics-request-16-0-stock_request_mrp
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-request&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows for users to be able to display manufacturing orders that have
been created as a consequence of Stock Requests.

**Table of contents**

.. contents::
:local:

Usage
=====

In case that the confirmation of the Stock Request results in an immediate
Manufacturing Order, the user will be able to display the MO's from the Stock
Request form view.

Known issues / Roadmap
======================

* When a Stock Request is cancelled, it does not cancel the quantity included
in the Manufacturing Order.

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-request/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/stock-logistics-request/issues/new?body=module:%20stock_request_mrp%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
~~~~~~~

* ForgeFlow

Contributors
~~~~~~~~~~~~

* Héctor Villarreal <hector.villarreal@forgeflow.com>.

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/stock-logistics-request <https://github.com/OCA/stock-logistics-request/tree/16.0/stock_request_mrp>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions stock_request_mrp/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from .hooks import post_init_hook
22 changes: 22 additions & 0 deletions stock_request_mrp/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2017-20 ForgeFlow S.L. (https://www.forgeflow.com)
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

{
"name": "Stock Request MRP",
"summary": "Manufacturing request for stock",
"version": "16.0.1.0.0",
"license": "LGPL-3",
"website": "https://github.com/OCA/stock-logistics-request",
"author": "ForgeFlow, Odoo Community Association (OCA)",
"category": "Warehouse Management",
"depends": ["stock_request", "mrp"],
"data": [
"security/ir.model.access.csv",
"views/stock_request_views.xml",
"views/stock_request_order_views.xml",
"views/mrp_production_views.xml",
],
"installable": True,
"auto_install": True,
"post_init_hook": "post_init_hook",
}
73 changes: 73 additions & 0 deletions stock_request_mrp/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Copyright 2020 ForgeFlow S.L. (https://www.forgeflow.com)
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

import logging

from odoo import SUPERUSER_ID, api

logger = logging.getLogger(__name__)


def post_init_hook(cr, registry):
"""
The objective of this hook is to link existing MOs
coming from a Stock Request.
"""
logger.info("Linking existing MOs coming from a Stock Request")
link_existing_mos_to_stock_request(cr)


def link_existing_mos_to_stock_request(cr):
env = api.Environment(cr, SUPERUSER_ID, dict())
stock_request_obj = env["stock.request"]
stock_request_order_obj = env["stock.request.order"]
stock_request_allocation_obj = env["stock.request.allocation"]
mrp_production_obj = env["mrp.production"]
mos_with_sr = mrp_production_obj.search([("origin", "ilike", "SR/%")])
logger.info("Linking %s MOs records" % len(mos_with_sr))
stock_requests = stock_request_obj.search(
[("name", "in", [mo.origin for mo in mos_with_sr])]
)
for mo in mos_with_sr:
stock_request = stock_requests.filtered(lambda x: x.name == mo.origin)
if stock_request:
# Link SR to MO
mo.stock_request_ids = [(6, 0, stock_request.ids)]
logger.info("MO {} linked to SR {}".format(mo.name, stock_request.name))
if (
not stock_request_allocation_obj.search(
[("stock_request_id", "=", stock_request.id)]
)
and mo.state != "cancel"
):
# Create allocation for finish move
logger.info("Create allocation for {}".format(stock_request.name))
mo.move_finished_ids[0].allocation_ids = [
(
0,
0,
{
"stock_request_id": request.id,
"requested_product_uom_qty": request.product_qty,
},
)
for request in mo.stock_request_ids
]

# Update allocations
logger.info("Updating Allocations for SR %s" % stock_request.name)
for ml in mo.finished_move_line_ids.filtered(
lambda m: m.exists() and m.move_id.allocation_ids
):
qty_done = ml.product_uom_id._compute_quantity(
ml.qty_done, ml.product_id.uom_id
)
to_allocate_qty = ml.qty_done
for allocation in ml.move_id.allocation_ids:
if allocation.open_product_qty:
allocated_qty = min(allocation.open_product_qty, qty_done)
allocation.allocated_product_qty += allocated_qty
to_allocate_qty -= allocated_qty
stock_request.check_done()
# Update production_ids from SROs
stock_request_order_obj.search([])._compute_production_ids()
74 changes: 74 additions & 0 deletions stock_request_mrp/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_request_mrp
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-11-11 18:36+0000\n"
"Last-Translator: Ivorra78 <informatica@totmaterial.es>\n"
"Language-Team: none\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: stock_request_mrp
#: model_terms:ir.ui.view,arch_db:stock_request_mrp.stock_request_order_form
#: model_terms:ir.ui.view,arch_db:stock_request_mrp.view_stock_request_form
msgid "MOs"
msgstr "MOs"

#. module: stock_request_mrp
#: model:ir.model.fields,field_description:stock_request_mrp.field_stock_request__production_ids
#: model:ir.model.fields,field_description:stock_request_mrp.field_stock_request_order__production_ids
msgid "Manufacturing Orders"
msgstr "Órdenes de Manufacturación"

#. module: stock_request_mrp
#: model:ir.model.fields,field_description:stock_request_mrp.field_stock_request__production_count
#: model:ir.model.fields,field_description:stock_request_mrp.field_stock_request_order__production_count
msgid "Manufacturing Orders count"
msgstr "Recuento de Órdenes de Fabricación"

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

#. module: stock_request_mrp
#: model:ir.model,name:stock_request_mrp.model_stock_request
msgid "Stock Request"
msgstr "Solicitud de Existencias"

#. module: stock_request_mrp
#: model:ir.model.fields,field_description:stock_request_mrp.field_mrp_production__stock_request_count
msgid "Stock Request #"
msgstr "Solicitud de Existencias #"

#. module: stock_request_mrp
#: model:ir.model,name:stock_request_mrp.model_stock_request_order
msgid "Stock Request Order"
msgstr "Solicitud de Pedido de Existencias"

#. module: stock_request_mrp
#: model:ir.model.fields,field_description:stock_request_mrp.field_mrp_production__stock_request_ids
#: model_terms:ir.ui.view,arch_db:stock_request_mrp.mrp_production_form_view
msgid "Stock Requests"
msgstr "Solicitudes de Existencias"

#. module: stock_request_mrp
#: model:ir.model,name:stock_request_mrp.model_stock_rule
msgid "Stock Rule"
msgstr "Regla de Existencias"

#. module: stock_request_mrp
#: code:addons/stock_request_mrp/models/stock_request.py:0
#, python-format
msgid ""
"You have linked to a Manufacture Order that belongs to another company."
msgstr ""
"Se ha vinculado a una orden de Fabricación que pertenece a otra empresa."
74 changes: 74 additions & 0 deletions stock_request_mrp/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_request_mrp
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-12-18 09:34+0000\n"
"Last-Translator: mymage <stefano.consolaro@mymage.it>\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: stock_request_mrp
#: model_terms:ir.ui.view,arch_db:stock_request_mrp.stock_request_order_form
#: model_terms:ir.ui.view,arch_db:stock_request_mrp.view_stock_request_form
msgid "MOs"
msgstr "OP"

#. module: stock_request_mrp
#: model:ir.model.fields,field_description:stock_request_mrp.field_stock_request__production_ids
#: model:ir.model.fields,field_description:stock_request_mrp.field_stock_request_order__production_ids
msgid "Manufacturing Orders"
msgstr "Ordini di produzione"

#. module: stock_request_mrp
#: model:ir.model.fields,field_description:stock_request_mrp.field_stock_request__production_count
#: model:ir.model.fields,field_description:stock_request_mrp.field_stock_request_order__production_count
msgid "Manufacturing Orders count"
msgstr "Numero ordini di produzione"

#. module: stock_request_mrp
#: model:ir.model,name:stock_request_mrp.model_mrp_production
msgid "Production Order"
msgstr "Ordine di produzione"

#. module: stock_request_mrp
#: model:ir.model,name:stock_request_mrp.model_stock_request
msgid "Stock Request"
msgstr "Richiesta di magazzino"

#. module: stock_request_mrp
#: model:ir.model.fields,field_description:stock_request_mrp.field_mrp_production__stock_request_count
msgid "Stock Request #"
msgstr "N° richieste di magazzino"

#. module: stock_request_mrp
#: model:ir.model,name:stock_request_mrp.model_stock_request_order
msgid "Stock Request Order"
msgstr "Ordine richiesta di magazzino"

#. module: stock_request_mrp
#: model:ir.model.fields,field_description:stock_request_mrp.field_mrp_production__stock_request_ids
#: model_terms:ir.ui.view,arch_db:stock_request_mrp.mrp_production_form_view
msgid "Stock Requests"
msgstr "Richieste di magazzino"

#. module: stock_request_mrp
#: model:ir.model,name:stock_request_mrp.model_stock_rule
msgid "Stock Rule"
msgstr "Regola di giacenza"

#. module: stock_request_mrp
#: code:addons/stock_request_mrp/models/stock_request.py:0
#, python-format
msgid ""
"You have linked to a Manufacture Order that belongs to another company."
msgstr ""
"È stato collegato un ordine di produzione che appartiene ad un'altra azienda."
Loading

0 comments on commit a85a4d4

Please sign in to comment.