diff --git a/stock_request_submit/README.rst b/stock_request_submit/README.rst new file mode 100644 index 000000000..b3cf2d189 --- /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/12.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-12-0/stock-logistics-warehouse-12-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/12.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 + + +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..0650744f6 --- /dev/null +++ b/stock_request_submit/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/stock_request_submit/__manifest__.py b/stock_request_submit/__manifest__.py new file mode 100644 index 000000000..90224e91d --- /dev/null +++ b/stock_request_submit/__manifest__.py @@ -0,0 +1,20 @@ +# Copyright 2019 Open Source Integrators +# Copyright 2019 Eficent Business and IT Consulting Services, S.L. +# License LGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Stock Request Submit", + "summary": "Add submit state on Stock Requests", + "version": "12.0.1.0.0", + "license": "LGPL-3", + "website": "https://github.com/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, +} 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..32b9ddc21 --- /dev/null +++ b/stock_request_submit/models/stock_request.py @@ -0,0 +1,36 @@ +# Copyright 2019 Open Source Integrators +# Copyright 2019 Eficent Business and IT Consulting Services, S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). +from odoo import api, fields, models + +REQUEST_STATES = [ + ('draft', 'Draft'), + ('submitted', 'Submitted'), + ('open', 'In progress'), + ('done', 'Done'), + ('cancel', 'Cancelled')] + + +class StockRequest(models.Model): + _inherit = 'stock.request' + + state = fields.Selection(selection=REQUEST_STATES, string='Status', + copy=False, default='draft', index=True, + readonly=True, track_visibility='onchange', + ) + route_id = fields.Many2one(states={'draft': [('readonly', False)], + 'submitted': [('readonly', False)]}, + readonly=True) + + @api.multi + def action_submit(self): + self._action_submit() + + @api.multi + def _action_submit(self): + self.state = 'submitted' + + def _skip_procurement(self): + return super(StockRequest, self)._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..0a0a4b41b --- /dev/null +++ b/stock_request_submit/models/stock_request_order.py @@ -0,0 +1,27 @@ +# Copyright 2019 Open Source Integrators +# Copyright 2019 Eficent Business and IT Consulting Services, S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). +from odoo import api, fields, models + +REQUEST_STATES = [ + ('draft', 'Draft'), + ('submitted', 'Submitted'), + ('open', 'In progress'), + ('done', 'Done'), + ('cancel', 'Cancelled')] + + +class StockRequestOrder(models.Model): + _inherit = 'stock.request.order' + + state = fields.Selection(selection=REQUEST_STATES, string='Status', + copy=False, default='draft', index=True, + readonly=True, track_visibility='onchange', + ) + + @api.multi + 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..1248d1ed6 --- /dev/null +++ b/stock_request_submit/readme/CONTRIBUTORS.rst @@ -0,0 +1,7 @@ +* `Open Source Integrators `_ + + * Maxime Chambreuil + * Steve Campbell + +* Héctor Villarreal Ortega + 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..d8ad5311f --- /dev/null +++ b/stock_request_submit/static/description/index.html @@ -0,0 +1,426 @@ + + + + + + +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
  • +
+
+ +
+

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..70d4ab22a --- /dev/null +++ b/stock_request_submit/tests/test_stock_request_submit.py @@ -0,0 +1,41 @@ +# Copyright 2017 Eficent Business and IT Consulting Services S.L. +# 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 + + +class TestStockRequestSubmit(test_stock_request.TestStockRequest): + + def setUp(self): + super(TestStockRequestSubmit, self).setUp() + + def test_stock_request_submit(self): + expected_date = fields.Date.today() + 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, + })] + } + + order = self.request_order.sudo( + self.stock_request_user).create(vals) + + stock_request = order.stock_request_ids + + self.product.route_ids = [(6, 0, self.route.ids)] + order.action_submit() + self.assertEqual(order.state, 'submitted') + self.assertEqual(stock_request.state, 'submitted') + order.action_confirm() + self.assertEqual(order.state, 'open') + self.assertEqual(stock_request.state, 'open') 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..089160dd5 --- /dev/null +++ b/stock_request_submit/views/stock_request_order_views.xml @@ -0,0 +1,34 @@ + + + + + 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..61efbc100 --- /dev/null +++ b/stock_request_submit/views/stock_request_views.xml @@ -0,0 +1,28 @@ + + + + + stock.request.form + stock.request + + + + + + + + + +