diff --git a/stock_request_direction/README.rst b/stock_request_direction/README.rst new file mode 100644 index 000000000..21cd7854d --- /dev/null +++ b/stock_request_direction/README.rst @@ -0,0 +1,21 @@ +**This file is going to be generated by oca-gen-addon-readme.** + +*Manual changes will be overwritten.* + +Please provide content in the ``readme`` directory: + +* **DESCRIPTION.rst** (required) +* INSTALL.rst (optional) +* CONFIGURE.rst (optional) +* **USAGE.rst** (optional, highly recommended) +* DEVELOP.rst (optional) +* ROADMAP.rst (optional) +* HISTORY.rst (optional, recommended) +* **CONTRIBUTORS.rst** (optional, highly recommended) +* CREDITS.rst (optional) + +Content of this README will also be drawn from the addon manifest, +from keys such as name, authors, maintainers, development_status, +and license. + +A good, one sentence summary in the manifest is also highly recommended. diff --git a/stock_request_direction/__init__.py b/stock_request_direction/__init__.py new file mode 100644 index 000000000..fcd348d59 --- /dev/null +++ b/stock_request_direction/__init__.py @@ -0,0 +1,4 @@ +# Copyright (c) 2019 Open Source Integrators +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +from . import models diff --git a/stock_request_direction/__manifest__.py b/stock_request_direction/__manifest__.py new file mode 100644 index 000000000..6c22c8a12 --- /dev/null +++ b/stock_request_direction/__manifest__.py @@ -0,0 +1,24 @@ +# Copyright (c) 2019 Open Source Integrators +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +{ + "name": "Stock Requests Direction", + "summary": "From or to your warehouse?", + "version": "12.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/res_config_settings.xml", + "views/stock_request_views.xml", + "views/stock_request_order_views.xml", + ], + "application": False, + "development_status": "Beta", + "maintainers": ["max3903"], +} diff --git a/stock_request_direction/models/__init__.py b/stock_request_direction/models/__init__.py new file mode 100644 index 000000000..010f84b16 --- /dev/null +++ b/stock_request_direction/models/__init__.py @@ -0,0 +1,5 @@ +# Copyright (c) 2019 Open Source Integrators +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +from . import stock_request +from . import stock_request_order diff --git a/stock_request_direction/models/stock_request.py b/stock_request_direction/models/stock_request.py new file mode 100644 index 000000000..732621286 --- /dev/null +++ b/stock_request_direction/models/stock_request.py @@ -0,0 +1,23 @@ +# Copyright (c) 2019 Open Source Integrators +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +from odoo import api, fields, models + + +class StockRequest(models.Model): + _inherit = "stock.request" + + direction = fields.Selection([('outbound', 'Outbound'), + ('inbound', 'Inbound')], + string='Direction', + states={'draft': [('readonly', False)]}, + readonly=True) + + @api.onchange('direction') + def _onchange_location_id(self): + if self.direction == 'outbound': + # Partner Locations/Customers + self.location_id = self.env.ref('stock.stock_location_customers') + else: + # Otherwise the Stock Location of the Warehouse + self.location_id = self.warehouse_id.lot_stock_id.id diff --git a/stock_request_direction/models/stock_request_order.py b/stock_request_direction/models/stock_request_order.py new file mode 100644 index 000000000..6ffbec931 --- /dev/null +++ b/stock_request_direction/models/stock_request_order.py @@ -0,0 +1,31 @@ +# Copyright (c) 2019 Open Source Integrators +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +from odoo import api, fields, models + + +class StockRequestOrder(models.Model): + _inherit = 'stock.request.order' + + direction = fields.Selection([('outbound', 'Outbound'), + ('inbound', 'Inbound')], + string='Direction', + states={'draft': [('readonly', False)]}, + readonly=True) + + @api.onchange('direction') + def _onchange_direction(self): + if self.direction == 'outbound': + # Stock Location set to Partner Locations/Customers + self.location_id = \ + self.company_id.partner_id.property_stock_customer.id + else: + # Otherwise the Stock Location of the Warehouse + self.location_id = \ + self.warehouse_id.lot_stock_id.id + + def change_childs(self): + super().change_childs() + if not self._context.get('no_change_childs', False): + for line in self.stock_request_ids: + line.direction = self.direction diff --git a/stock_request_direction/readme/CONTRIBUTORS.rst b/stock_request_direction/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..353b9c62d --- /dev/null +++ b/stock_request_direction/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* `Open Source Integrators `_ + + * Maxime Chambreuil + * Steve Campbell diff --git a/stock_request_direction/readme/DESCRIPTION.rst b/stock_request_direction/readme/DESCRIPTION.rst new file mode 100644 index 000000000..8620293b1 --- /dev/null +++ b/stock_request_direction/readme/DESCRIPTION.rst @@ -0,0 +1,3 @@ +This module was written to allow users to request products to be transferred +from or to your warehouses. They can specify the direction and don't have to +bother selecting the inventory location. diff --git a/stock_request_direction/readme/USAGE.rst b/stock_request_direction/readme/USAGE.rst new file mode 100644 index 000000000..22156f016 --- /dev/null +++ b/stock_request_direction/readme/USAGE.rst @@ -0,0 +1,19 @@ +Creation +~~~~~~~~ + +* Go to Stock Requests > Stock Requests +* Create or select a stock request +* Provide a product, quantity, direction and expected date +* Click Confirm + +Upon confirmation, the request will be reviewed by the warehouse team who can +define the appropriate route. + +In case that transfers are created, the user will be able to access to them +from the button 'Transfers' available in the Stock Request. + +Cancel +~~~~~~ + +When the user cancels a Stock Request, the related pending stock moves will be +also cancelled. diff --git a/stock_request_direction/static/description/icon.png b/stock_request_direction/static/description/icon.png new file mode 100644 index 000000000..c31ecfd9f Binary files /dev/null and b/stock_request_direction/static/description/icon.png differ diff --git a/stock_request_direction/views/res_config_settings.xml b/stock_request_direction/views/res_config_settings.xml new file mode 100644 index 000000000..419bc78a3 --- /dev/null +++ b/stock_request_direction/views/res_config_settings.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + diff --git a/stock_request_direction/views/stock_request_order_views.xml b/stock_request_direction/views/stock_request_order_views.xml new file mode 100644 index 000000000..0c472e6e1 --- /dev/null +++ b/stock_request_direction/views/stock_request_order_views.xml @@ -0,0 +1,43 @@ + + + + + + stock.request.order.tree + stock.request.order + + + + + + + + + + stock.request.order.form + stock.request.order + + + + + + + { + 'default_expected_date': expected_date, + 'default_picking_policy': picking_policy, + 'default_warehouse_id': warehouse_id, + 'default_direction': direction, + 'default_location_id': location_id, + 'default_procurement_group_id': procurement_group_id, + 'default_company_id': company_id, + 'default_state': state, + } + + + + + + + + diff --git a/stock_request_direction/views/stock_request_views.xml b/stock_request_direction/views/stock_request_views.xml new file mode 100644 index 000000000..ed3e586c6 --- /dev/null +++ b/stock_request_direction/views/stock_request_views.xml @@ -0,0 +1,28 @@ + + + + + + stock.request.tree + stock.request + + + + + + + + + + stock.request.form + stock.request + + + + + + + + +