diff --git a/stock_request_submit/README.rst b/stock_request_submit/README.rst new file mode 100644 index 000000000..036404b1a --- /dev/null +++ b/stock_request_submit/README.rst @@ -0,0 +1,82 @@ +==================== +Stock Request Submit +==================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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--warehouse-lightgray.png?logo=github + :target: https://github.com/OCA/stock-logistics-warehouse/tree/14.0/stock_request_submit + :alt: OCA/stock-logistics-warehouse +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-13-0/stock-logistics-warehouse-13-0-stock_request_submit + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/153/14.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds a new state 'Submitted' to Stock Request. + +The porpose of this state is to allow Supervisors to validate the submitted +request enabling them to correct Routes if required. + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Open Source Integrators + +Contributors +~~~~~~~~~~~~ + +* `Open Source Integrators `_ + + * Maxime Chambreuil + * Steve Campbell + +* Héctor Villarreal Ortega +* Pimolnat Suntian + +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-warehouse `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/stock_request_submit/__init__.py b/stock_request_submit/__init__.py new file mode 100644 index 000000000..071962a35 --- /dev/null +++ b/stock_request_submit/__init__.py @@ -0,0 +1,2 @@ +from . import models +from .hooks import uninstall_hook diff --git a/stock_request_submit/__manifest__.py b/stock_request_submit/__manifest__.py new file mode 100644 index 000000000..9e498e53c --- /dev/null +++ b/stock_request_submit/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2019 Open Source Integrators +# Copyright 2019-2020 ForgeFlow S.L. (https://www.forgeflow.com) +# License LGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Stock Request Submit", + "summary": "Add submit state on Stock Requests", + "version": "14.0.1.0.0", + "license": "LGPL-3", + "website": "https://github.com/OCA/stock-logistics-warehouse", + "author": "Open Source Integrators, Odoo Community Association (OCA)", + "category": "Warehouse Management", + "depends": ["stock_request"], + "data": ["views/stock_request_order_views.xml", "views/stock_request_views.xml"], + "installable": True, + "uninstall_hook": "uninstall_hook", +} diff --git a/stock_request_submit/hooks.py b/stock_request_submit/hooks.py new file mode 100644 index 000000000..1cbb1e018 --- /dev/null +++ b/stock_request_submit/hooks.py @@ -0,0 +1,11 @@ +# Copyright 2019-2020 ForgeFlow S.L. (https://www.forgeflow.com) +# License LGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo import SUPERUSER_ID, api + + +def uninstall_hook(cr, registry): + env = api.Environment(cr, SUPERUSER_ID, {}) + sr = env["stock.request"].search([("state", "=", "submitted")]) + sr.write({"state": "draft"}) + sro = env["stock.request.order"].search([("state", "=", "submitted")]) + sro.write({"state": "draft"}) diff --git a/stock_request_submit/i18n/es.po b/stock_request_submit/i18n/es.po new file mode 100644 index 000000000..44aa62c22 --- /dev/null +++ b/stock_request_submit/i18n/es.po @@ -0,0 +1,44 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_request_submit +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2020-01-17 05:13+0000\n" +"Last-Translator: Nelson Ramírez Sánchez \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 3.10\n" + +#. module: stock_request_submit +#: model:ir.model.fields,field_description:stock_request_submit.field_stock_request__route_id +msgid "Route" +msgstr "Ruta" + +#. module: stock_request_submit +#: model:ir.model,name:stock_request_submit.model_stock_request +msgid "Stock Request" +msgstr "Solicitud de Stock" + +#. module: stock_request_submit +#: model:ir.model,name:stock_request_submit.model_stock_request_order +msgid "Stock Request Order" +msgstr "Pedido de solicitud de stock" + +#. module: stock_request_submit +#: model_terms:ir.ui.view,arch_db:stock_request_submit.stock_request_order_form +#: model_terms:ir.ui.view,arch_db:stock_request_submit.view_stock_request_form +msgid "Submit" +msgstr "Enviar" + +#~ msgid "Draft" +#~ msgstr "Borrador" + +#~ msgid "Submitted" +#~ msgstr "Enviada" diff --git a/stock_request_submit/i18n/stock_request_submit.pot b/stock_request_submit/i18n/stock_request_submit.pot new file mode 100644 index 000000000..bd2c350d0 --- /dev/null +++ b/stock_request_submit/i18n/stock_request_submit.pot @@ -0,0 +1,35 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_request_submit +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \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: stock_request_submit +#: model:ir.model.fields,field_description:stock_request_submit.field_stock_request__route_id +msgid "Route" +msgstr "" + +#. module: stock_request_submit +#: model:ir.model,name:stock_request_submit.model_stock_request +msgid "Stock Request" +msgstr "" + +#. module: stock_request_submit +#: model:ir.model,name:stock_request_submit.model_stock_request_order +msgid "Stock Request Order" +msgstr "" + +#. module: stock_request_submit +#: model_terms:ir.ui.view,arch_db:stock_request_submit.stock_request_order_form +#: model_terms:ir.ui.view,arch_db:stock_request_submit.view_stock_request_form +msgid "Submit" +msgstr "" diff --git a/stock_request_submit/i18n/zh_CN.po b/stock_request_submit/i18n/zh_CN.po new file mode 100644 index 000000000..265566a5a --- /dev/null +++ b/stock_request_submit/i18n/zh_CN.po @@ -0,0 +1,44 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_request_submit +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2019-10-16 15:58+0000\n" +"Last-Translator: 黎伟杰 <674416404@qq.com>\n" +"Language-Team: none\n" +"Language: zh_CN\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=1; plural=0;\n" +"X-Generator: Weblate 3.8\n" + +#. module: stock_request_submit +#: model:ir.model.fields,field_description:stock_request_submit.field_stock_request__route_id +msgid "Route" +msgstr "路线" + +#. module: stock_request_submit +#: model:ir.model,name:stock_request_submit.model_stock_request +msgid "Stock Request" +msgstr "库存请求" + +#. module: stock_request_submit +#: model:ir.model,name:stock_request_submit.model_stock_request_order +msgid "Stock Request Order" +msgstr "库存请求单" + +#. module: stock_request_submit +#: model_terms:ir.ui.view,arch_db:stock_request_submit.stock_request_order_form +#: model_terms:ir.ui.view,arch_db:stock_request_submit.view_stock_request_form +msgid "Submit" +msgstr "提交" + +#~ msgid "Draft" +#~ msgstr "草稿" + +#~ msgid "Submitted" +#~ msgstr "已提交" diff --git a/stock_request_submit/models/__init__.py b/stock_request_submit/models/__init__.py new file mode 100644 index 000000000..3255e7ebd --- /dev/null +++ b/stock_request_submit/models/__init__.py @@ -0,0 +1,2 @@ +from . import stock_request +from . import stock_request_order diff --git a/stock_request_submit/models/stock_request.py b/stock_request_submit/models/stock_request.py new file mode 100644 index 000000000..973df1bbc --- /dev/null +++ b/stock_request_submit/models/stock_request.py @@ -0,0 +1,34 @@ +# Copyright 2019 Open Source Integrators +# Copyright 2019-2020 ForgeFlow S.L. (https://www.forgeflow.com) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +from odoo import fields, models + + +class StockRequest(models.Model): + _inherit = "stock.request" + + def __get_request_states(self): + states = super().__get_request_states() + if not ("submitted", "Submitted") in states: + states.insert( + states.index(("draft", "Draft")) + 1, ("submitted", "Submitted") + ) + return states + + route_id = fields.Many2one( + states={"draft": [("readonly", False)], "submitted": [("readonly", False)]} + ) + + def action_submit(self): + self._action_submit() + + def _action_submit(self): + self.state = "submitted" + + def _skip_procurement(self): + return ( + super()._skip_procurement() + and self.state != "submitted" + or self.product_id.type not in ("consu", "product") + ) diff --git a/stock_request_submit/models/stock_request_order.py b/stock_request_submit/models/stock_request_order.py new file mode 100644 index 000000000..7a4066173 --- /dev/null +++ b/stock_request_submit/models/stock_request_order.py @@ -0,0 +1,15 @@ +# Copyright 2019 Open Source Integrators +# Copyright 2019-2020 ForgeFlow S.L. (https://www.forgeflow.com) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +from odoo import models + + +class StockRequestOrder(models.Model): + _inherit = "stock.request.order" + + def action_submit(self): + for line in self.stock_request_ids: + line.action_submit() + self.state = "submitted" + return True diff --git a/stock_request_submit/readme/CONTRIBUTORS.rst b/stock_request_submit/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..63e314425 --- /dev/null +++ b/stock_request_submit/readme/CONTRIBUTORS.rst @@ -0,0 +1,7 @@ +* `Open Source Integrators `_ + + * Maxime Chambreuil + * Steve Campbell + +* Héctor Villarreal Ortega +* Pimolnat Suntian diff --git a/stock_request_submit/readme/DESCRIPTION.rst b/stock_request_submit/readme/DESCRIPTION.rst new file mode 100644 index 000000000..b7de78aa7 --- /dev/null +++ b/stock_request_submit/readme/DESCRIPTION.rst @@ -0,0 +1,4 @@ +This module adds a new state 'Submitted' to Stock Request. + +The porpose of this state is to allow Supervisors to validate the submitted +request enabling them to correct Routes if required. diff --git a/stock_request_submit/static/description/icon.png b/stock_request_submit/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/stock_request_submit/static/description/icon.png differ diff --git a/stock_request_submit/static/description/index.html b/stock_request_submit/static/description/index.html new file mode 100644 index 000000000..7105dfd52 --- /dev/null +++ b/stock_request_submit/static/description/index.html @@ -0,0 +1,427 @@ + + + + + + +Stock Request Submit + + + +
+

Stock Request Submit

+ + +

Beta License: LGPL-3 OCA/stock-logistics-warehouse Translate me on Weblate Try me on Runbot

+

This module adds a new state ‘Submitted’ to Stock Request.

+

The porpose of this state is to allow Supervisors to validate the submitted +request enabling them to correct Routes if required.

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Open Source Integrators
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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-warehouse project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/stock_request_submit/tests/__init__.py b/stock_request_submit/tests/__init__.py new file mode 100644 index 000000000..a5ec52c4d --- /dev/null +++ b/stock_request_submit/tests/__init__.py @@ -0,0 +1 @@ +from . import test_stock_request_submit diff --git a/stock_request_submit/tests/test_stock_request_submit.py b/stock_request_submit/tests/test_stock_request_submit.py new file mode 100644 index 000000000..f905bf86c --- /dev/null +++ b/stock_request_submit/tests/test_stock_request_submit.py @@ -0,0 +1,60 @@ +# Copyright 2017-2020 ForgeFlow S.L. (https://www.forgeflow.com) +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl-3.0). + +from odoo import fields + +from odoo.addons.stock_request.tests import test_stock_request + +from ..hooks import uninstall_hook + + +class TestStockRequestSubmit(test_stock_request.TestStockRequest): + def setUp(self): + super().setUp() + expected_date = fields.Datetime.now() + vals = { + "company_id": self.main_company.id, + "warehouse_id": self.warehouse.id, + "location_id": self.warehouse.lot_stock_id.id, + "expected_date": expected_date, + "stock_request_ids": [ + ( + 0, + 0, + { + "product_id": self.product.id, + "product_uom_id": self.product.uom_id.id, + "product_uom_qty": 5.0, + "company_id": self.main_company.id, + "warehouse_id": self.warehouse.id, + "location_id": self.warehouse.lot_stock_id.id, + "expected_date": expected_date, + }, + ) + ], + } + self.order = self.request_order.with_user(self.stock_request_user).create(vals) + self.stock_request = self.order.stock_request_ids + + def test_stock_request_submit(self): + self.product.route_ids = [(6, 0, self.route.ids)] + self.order.action_submit() + self.assertEqual(self.order.state, "submitted") + self.assertEqual(self.stock_request.state, "submitted") + self.order.action_confirm() + self.assertEqual(self.order.state, "open") + self.assertEqual(self.stock_request.state, "open") + + def test_uninstall_hook(self): + # Check state before uninstall + self.product.route_ids = [(6, 0, self.route.ids)] + self.order.action_submit() + self.assertEqual(self.order.state, "submitted") + self.assertEqual(self.stock_request.state, "submitted") + + # Uninstall this module + uninstall_hook(self.cr, self.registry) + + # Check state after uninstall + self.assertEqual(self.order.state, "draft") + self.assertEqual(self.stock_request.state, "draft") diff --git a/stock_request_submit/views/stock_request_order_views.xml b/stock_request_submit/views/stock_request_order_views.xml new file mode 100644 index 000000000..d870f7b73 --- /dev/null +++ b/stock_request_submit/views/stock_request_order_views.xml @@ -0,0 +1,41 @@ + + + + stock.request.order.form + stock.request.order + + + + + + + + {'readonly': [('state', 'not in', ['draft', 'submitted'])]} + + + {'readonly': [('state', 'not in', ['draft', 'submitted'])]} + + + + diff --git a/stock_request_submit/views/stock_request_views.xml b/stock_request_submit/views/stock_request_views.xml new file mode 100644 index 000000000..4fc7deddf --- /dev/null +++ b/stock_request_submit/views/stock_request_views.xml @@ -0,0 +1,31 @@ + + + + stock.request.form + stock.request + + + + + + + + +