Skip to content

Commit 7f47fe6

Browse files
committed
Merge PR #52 into 18.0
Signed-off-by LoisRForgeFlow
2 parents 58ca6a3 + 0ecce99 commit 7f47fe6

25 files changed

+1344
-0
lines changed

stock_request_mrp/README.rst

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
=================
2+
Stock Request MRP
3+
=================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:a6b45dcb2fb143635915a3facfcf470c2193c3f65e7b5452f39f7b80f5bf1ce5
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
18+
:alt: License: LGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--request-lightgray.png?logo=github
20+
:target: https://github.com/OCA/stock-logistics-request/tree/18.0/stock_request_mrp
21+
:alt: OCA/stock-logistics-request
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/stock-logistics-request-18-0/stock-logistics-request-18-0-stock_request_mrp
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-request&target_branch=18.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module allows users to be able to display Manufacturing Orders that
32+
have been created as a consequence of Stock Requests.
33+
34+
**Table of contents**
35+
36+
.. contents::
37+
:local:
38+
39+
Usage
40+
=====
41+
42+
In case that the confirmation of the Stock Request results in an
43+
immediate Manufacturing Order, the user will be able to display the MO's
44+
from the Stock Request form view.
45+
46+
Navigate to Stock Requests and create a new stock request. Upon
47+
confirmation of the stock request, the system will automatically
48+
generate the corresponding manufacturing order. View and manage the
49+
generated manufacturing orders directly from the stock request record or
50+
through Manufacturing.
51+
52+
Known issues / Roadmap
53+
======================
54+
55+
56+
57+
Bug Tracker
58+
===========
59+
60+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-request/issues>`_.
61+
In case of trouble, please check there if your issue has already been reported.
62+
If you spotted it first, help us to smash it by providing a detailed and welcomed
63+
`feedback <https://github.com/OCA/stock-logistics-request/issues/new?body=module:%20stock_request_mrp%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
64+
65+
Do not contact contributors directly about support or help with technical issues.
66+
67+
Credits
68+
=======
69+
70+
Authors
71+
-------
72+
73+
* ForgeFlow
74+
75+
Contributors
76+
------------
77+
78+
- Héctor Villarreal <[email protected]>.
79+
80+
Maintainers
81+
-----------
82+
83+
This module is maintained by the OCA.
84+
85+
.. image:: https://odoo-community.org/logo.png
86+
:alt: Odoo Community Association
87+
:target: https://odoo-community.org
88+
89+
OCA, or the Odoo Community Association, is a nonprofit organization whose
90+
mission is to support the collaborative development of Odoo features and
91+
promote its widespread use.
92+
93+
.. |maintainer-LoisRForgeFlow| image:: https://github.com/LoisRForgeFlow.png?size=40px
94+
:target: https://github.com/LoisRForgeFlow
95+
:alt: LoisRForgeFlow
96+
.. |maintainer-etobella| image:: https://github.com/etobella.png?size=40px
97+
:target: https://github.com/etobella
98+
:alt: etobella
99+
100+
Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:
101+
102+
|maintainer-LoisRForgeFlow| |maintainer-etobella|
103+
104+
This module is part of the `OCA/stock-logistics-request <https://github.com/OCA/stock-logistics-request/tree/18.0/stock_request_mrp>`_ project on GitHub.
105+
106+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

stock_request_mrp/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from . import models
2+
from .hooks import post_init_hook

stock_request_mrp/__manifest__.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright 2017-24 ForgeFlow S.L. (https://www.forgeflow.com)
2+
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
3+
4+
{
5+
"name": "Stock Request MRP",
6+
"summary": "Manufacturing request for stock",
7+
"version": "18.0.1.0.0",
8+
"license": "LGPL-3",
9+
"website": "https://github.com/OCA/stock-logistics-request",
10+
"author": "ForgeFlow, Odoo Community Association (OCA)",
11+
"maintainers": ["LoisRForgeFlow", "etobella"],
12+
"category": "Warehouse Management",
13+
"depends": ["stock_request", "mrp"],
14+
"data": [
15+
"security/ir.model.access.csv",
16+
"views/stock_request_views.xml",
17+
"views/stock_request_order_views.xml",
18+
"views/mrp_production_views.xml",
19+
],
20+
"installable": True,
21+
"auto_install": True,
22+
"post_init_hook": "post_init_hook",
23+
}

stock_request_mrp/hooks.py

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Copyright 2020-24 ForgeFlow S.L. (https://www.forgeflow.com)
2+
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
3+
4+
import logging
5+
6+
from odoo import SUPERUSER_ID, api
7+
8+
logger = logging.getLogger(__name__)
9+
10+
11+
def post_init_hook(env):
12+
"""
13+
The objective of this hook is to link existing MOs
14+
coming from a Stock Request.
15+
"""
16+
logger.info("Linking existing MOs coming from a Stock Request")
17+
link_existing_mos_to_stock_request(env)
18+
19+
20+
def link_existing_mos_to_stock_request(env):
21+
env = api.Environment(env.cr, SUPERUSER_ID, dict())
22+
stock_request_obj = env["stock.request"]
23+
stock_request_order_obj = env["stock.request.order"]
24+
stock_request_allocation_obj = env["stock.request.allocation"]
25+
mrp_production_obj = env["mrp.production"]
26+
mos_with_sr = mrp_production_obj.search([("origin", "ilike", "SR/%")])
27+
logger.info(f"Linking {len(mos_with_sr)} MOs records")
28+
stock_requests = stock_request_obj.search(
29+
[("name", "in", [mo.origin for mo in mos_with_sr])]
30+
)
31+
for mo in mos_with_sr:
32+
stock_request = stock_requests.filtered(lambda x, mo=mo: x.name == mo.origin)
33+
if stock_request:
34+
# Link SR to MO
35+
mo.stock_request_ids = [(6, 0, stock_request.ids)]
36+
logger.info(f"MO {mo.name} linked to SR {stock_request.name}")
37+
if (
38+
not stock_request_allocation_obj.search(
39+
[("stock_request_id", "=", stock_request.id)]
40+
)
41+
and mo.state != "cancel"
42+
):
43+
# Create allocation for finish move
44+
logger.info(f"Create allocation for {stock_request.name}")
45+
mo.move_finished_ids[0].allocation_ids = [
46+
(
47+
0,
48+
0,
49+
{
50+
"stock_request_id": request.id,
51+
"requested_product_uom_qty": request.product_qty,
52+
},
53+
)
54+
for request in mo.stock_request_ids
55+
]
56+
57+
# Update allocations
58+
logger.info(f"Updating Allocations for SR {stock_request.name}")
59+
for ml in mo.finished_move_line_ids.filtered(
60+
lambda m: m.exists() and m.move_id.allocation_ids
61+
):
62+
quantity = ml.product_uom_id._compute_quantity(
63+
ml.quantity, ml.product_id.uom_id
64+
)
65+
to_allocate_qty = ml.quantity
66+
for allocation in ml.move_id.allocation_ids:
67+
if allocation.open_product_qty:
68+
allocated_qty = min(allocation.open_product_qty, quantity)
69+
allocation.allocated_product_qty += allocated_qty
70+
to_allocate_qty -= allocated_qty
71+
stock_request.check_done()
72+
# Update production_ids from SROs
73+
stock_request_order_obj.search([])._compute_production_ids()

stock_request_mrp/i18n/es.po

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * stock_request_mrp
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 15.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"PO-Revision-Date: 2023-11-11 18:36+0000\n"
10+
"Last-Translator: Ivorra78 <[email protected]>\n"
11+
"Language-Team: none\n"
12+
"Language: es\n"
13+
"MIME-Version: 1.0\n"
14+
"Content-Type: text/plain; charset=UTF-8\n"
15+
"Content-Transfer-Encoding: \n"
16+
"Plural-Forms: nplurals=2; plural=n != 1;\n"
17+
"X-Generator: Weblate 4.17\n"
18+
19+
#. module: stock_request_mrp
20+
#: model_terms:ir.ui.view,arch_db:stock_request_mrp.stock_request_order_form
21+
#: model_terms:ir.ui.view,arch_db:stock_request_mrp.view_stock_request_form
22+
msgid "MOs"
23+
msgstr "MOs"
24+
25+
#. module: stock_request_mrp
26+
#: model:ir.model.fields,field_description:stock_request_mrp.field_stock_request__production_ids
27+
#: model:ir.model.fields,field_description:stock_request_mrp.field_stock_request_order__production_ids
28+
msgid "Manufacturing Orders"
29+
msgstr "Órdenes de Manufacturación"
30+
31+
#. module: stock_request_mrp
32+
#: model:ir.model.fields,field_description:stock_request_mrp.field_stock_request__production_count
33+
#: model:ir.model.fields,field_description:stock_request_mrp.field_stock_request_order__production_count
34+
msgid "Manufacturing Orders count"
35+
msgstr "Recuento de Órdenes de Fabricación"
36+
37+
#. module: stock_request_mrp
38+
#: model:ir.model,name:stock_request_mrp.model_mrp_production
39+
msgid "Production Order"
40+
msgstr "Orden de Producción"
41+
42+
#. module: stock_request_mrp
43+
#: model:ir.model,name:stock_request_mrp.model_stock_request
44+
msgid "Stock Request"
45+
msgstr "Solicitud de Existencias"
46+
47+
#. module: stock_request_mrp
48+
#: model:ir.model.fields,field_description:stock_request_mrp.field_mrp_production__stock_request_count
49+
msgid "Stock Request #"
50+
msgstr "Solicitud de Existencias #"
51+
52+
#. module: stock_request_mrp
53+
#: model:ir.model,name:stock_request_mrp.model_stock_request_order
54+
msgid "Stock Request Order"
55+
msgstr "Solicitud de Pedido de Existencias"
56+
57+
#. module: stock_request_mrp
58+
#: model:ir.model.fields,field_description:stock_request_mrp.field_mrp_production__stock_request_ids
59+
#: model_terms:ir.ui.view,arch_db:stock_request_mrp.mrp_production_form_view
60+
msgid "Stock Requests"
61+
msgstr "Solicitudes de Existencias"
62+
63+
#. module: stock_request_mrp
64+
#: model:ir.model,name:stock_request_mrp.model_stock_rule
65+
msgid "Stock Rule"
66+
msgstr "Regla de Existencias"
67+
68+
#. module: stock_request_mrp
69+
#. odoo-python
70+
#: code:addons/stock_request_mrp/models/stock_request.py:0
71+
#, python-format
72+
msgid "You have linked to a Manufacture Order that belongs to another company."
73+
msgstr ""
74+
"Se ha vinculado a una orden de Fabricación que pertenece a otra empresa."

stock_request_mrp/i18n/it.po

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * stock_request_mrp
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 15.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"PO-Revision-Date: 2023-12-18 09:34+0000\n"
10+
"Last-Translator: mymage <[email protected]>\n"
11+
"Language-Team: none\n"
12+
"Language: it\n"
13+
"MIME-Version: 1.0\n"
14+
"Content-Type: text/plain; charset=UTF-8\n"
15+
"Content-Transfer-Encoding: \n"
16+
"Plural-Forms: nplurals=2; plural=n != 1;\n"
17+
"X-Generator: Weblate 4.17\n"
18+
19+
#. module: stock_request_mrp
20+
#: model_terms:ir.ui.view,arch_db:stock_request_mrp.stock_request_order_form
21+
#: model_terms:ir.ui.view,arch_db:stock_request_mrp.view_stock_request_form
22+
msgid "MOs"
23+
msgstr "OP"
24+
25+
#. module: stock_request_mrp
26+
#: model:ir.model.fields,field_description:stock_request_mrp.field_stock_request__production_ids
27+
#: model:ir.model.fields,field_description:stock_request_mrp.field_stock_request_order__production_ids
28+
msgid "Manufacturing Orders"
29+
msgstr "Ordini di produzione"
30+
31+
#. module: stock_request_mrp
32+
#: model:ir.model.fields,field_description:stock_request_mrp.field_stock_request__production_count
33+
#: model:ir.model.fields,field_description:stock_request_mrp.field_stock_request_order__production_count
34+
msgid "Manufacturing Orders count"
35+
msgstr "Numero ordini di produzione"
36+
37+
#. module: stock_request_mrp
38+
#: model:ir.model,name:stock_request_mrp.model_mrp_production
39+
msgid "Production Order"
40+
msgstr "Ordine di produzione"
41+
42+
#. module: stock_request_mrp
43+
#: model:ir.model,name:stock_request_mrp.model_stock_request
44+
msgid "Stock Request"
45+
msgstr "Richiesta di magazzino"
46+
47+
#. module: stock_request_mrp
48+
#: model:ir.model.fields,field_description:stock_request_mrp.field_mrp_production__stock_request_count
49+
msgid "Stock Request #"
50+
msgstr "N° richieste di magazzino"
51+
52+
#. module: stock_request_mrp
53+
#: model:ir.model,name:stock_request_mrp.model_stock_request_order
54+
msgid "Stock Request Order"
55+
msgstr "Ordine richiesta di magazzino"
56+
57+
#. module: stock_request_mrp
58+
#: model:ir.model.fields,field_description:stock_request_mrp.field_mrp_production__stock_request_ids
59+
#: model_terms:ir.ui.view,arch_db:stock_request_mrp.mrp_production_form_view
60+
msgid "Stock Requests"
61+
msgstr "Richieste di magazzino"
62+
63+
#. module: stock_request_mrp
64+
#: model:ir.model,name:stock_request_mrp.model_stock_rule
65+
msgid "Stock Rule"
66+
msgstr "Regola di giacenza"
67+
68+
#. module: stock_request_mrp
69+
#. odoo-python
70+
#: code:addons/stock_request_mrp/models/stock_request.py:0
71+
#, python-format
72+
msgid "You have linked to a Manufacture Order that belongs to another company."
73+
msgstr ""
74+
"È stato collegato un ordine di produzione che appartiene ad un'altra azienda."

0 commit comments

Comments
 (0)