diff --git a/setup/stock_request_direction/odoo/addons/stock_request_direction b/setup/stock_request_direction/odoo/addons/stock_request_direction new file mode 120000 index 00000000..0e365a6c --- /dev/null +++ b/setup/stock_request_direction/odoo/addons/stock_request_direction @@ -0,0 +1 @@ +../../../../stock_request_direction \ No newline at end of file diff --git a/setup/stock_request_direction/setup.py b/setup/stock_request_direction/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/stock_request_direction/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_request_direction/README.rst b/stock_request_direction/README.rst new file mode 100644 index 00000000..f36ee888 --- /dev/null +++ b/stock_request_direction/README.rst @@ -0,0 +1,121 @@ +======================== +Stock Requests Direction +======================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:82fa2af82b3f4697cc02afc9e91a6553fdeeb25b54776fe9d0a66a481ff62a88 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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_direction + :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_direction + :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 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. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +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. + +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 to smash 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 + * Freni Patel + +* `Ecosoft `__: + + * Pimolnat Suntian + * Kitti U. + +* `[APSL](https://apsl.tech)`__: + * Antoni Marroig + +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. + +.. |maintainer-max3903| image:: https://github.com/max3903.png?size=40px + :target: https://github.com/max3903 + :alt: max3903 + +Current `maintainer `__: + +|maintainer-max3903| + +This module is part of the `OCA/stock-logistics-request `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/stock_request_direction/__init__.py b/stock_request_direction/__init__.py new file mode 100644 index 00000000..fcd348d5 --- /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 00000000..b756c71f --- /dev/null +++ b/stock_request_direction/__manifest__.py @@ -0,0 +1,21 @@ +# 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": "16.0.1.0.0", + "license": "LGPL-3", + "website": "https://github.com/OCA/stock-logistics-request", + "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/i18n/es.po b/stock_request_direction/i18n/es.po new file mode 100644 index 00000000..7edc8c6e --- /dev/null +++ b/stock_request_direction/i18n/es.po @@ -0,0 +1,63 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_request_direction +# +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_direction +#: model:ir.model.fields,field_description:stock_request_direction.field_stock_request__direction +#: model:ir.model.fields,field_description:stock_request_direction.field_stock_request_order__direction +msgid "Direction" +msgstr "Sentido" + +#. module: stock_request_direction +#: model:ir.model.fields,field_description:stock_request_direction.field_stock_request__display_name +#: model:ir.model.fields,field_description:stock_request_direction.field_stock_request_order__display_name +msgid "Display Name" +msgstr "" + +#. module: stock_request_direction +#: model:ir.model.fields,field_description:stock_request_direction.field_stock_request__id +#: model:ir.model.fields,field_description:stock_request_direction.field_stock_request_order__id +msgid "ID" +msgstr "" + +#. module: stock_request_direction +#: model:ir.model.fields.selection,name:stock_request_direction.selection__stock_request__direction__inbound +#: model:ir.model.fields.selection,name:stock_request_direction.selection__stock_request_order__direction__inbound +msgid "Inbound" +msgstr "Entrante" + +#. module: stock_request_direction +#: model:ir.model.fields,field_description:stock_request_direction.field_stock_request____last_update +#: model:ir.model.fields,field_description:stock_request_direction.field_stock_request_order____last_update +msgid "Last Modified on" +msgstr "" + +#. module: stock_request_direction +#: model:ir.model.fields.selection,name:stock_request_direction.selection__stock_request__direction__outbound +#: model:ir.model.fields.selection,name:stock_request_direction.selection__stock_request_order__direction__outbound +msgid "Outbound" +msgstr "Saliente" + +#. module: stock_request_direction +#: model:ir.model,name:stock_request_direction.model_stock_request +msgid "Stock Request" +msgstr "Solicitud de Existencias" + +#. module: stock_request_direction +#: model:ir.model,name:stock_request_direction.model_stock_request_order +msgid "Stock Request Order" +msgstr "Pedido de Existencia" diff --git a/stock_request_direction/i18n/it.po b/stock_request_direction/i18n/it.po new file mode 100644 index 00000000..f1e999b5 --- /dev/null +++ b/stock_request_direction/i18n/it.po @@ -0,0 +1,63 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_request_direction +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-01-15 11:34+0000\n" +"Last-Translator: mymage \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_direction +#: model:ir.model.fields,field_description:stock_request_direction.field_stock_request__direction +#: model:ir.model.fields,field_description:stock_request_direction.field_stock_request_order__direction +msgid "Direction" +msgstr "Direzione" + +#. module: stock_request_direction +#: model:ir.model.fields,field_description:stock_request_direction.field_stock_request__display_name +#: model:ir.model.fields,field_description:stock_request_direction.field_stock_request_order__display_name +msgid "Display Name" +msgstr "Nome visualizzato" + +#. module: stock_request_direction +#: model:ir.model.fields,field_description:stock_request_direction.field_stock_request__id +#: model:ir.model.fields,field_description:stock_request_direction.field_stock_request_order__id +msgid "ID" +msgstr "ID" + +#. module: stock_request_direction +#: model:ir.model.fields.selection,name:stock_request_direction.selection__stock_request__direction__inbound +#: model:ir.model.fields.selection,name:stock_request_direction.selection__stock_request_order__direction__inbound +msgid "Inbound" +msgstr "In entrata" + +#. module: stock_request_direction +#: model:ir.model.fields,field_description:stock_request_direction.field_stock_request____last_update +#: model:ir.model.fields,field_description:stock_request_direction.field_stock_request_order____last_update +msgid "Last Modified on" +msgstr "Ultima modifica il" + +#. module: stock_request_direction +#: model:ir.model.fields.selection,name:stock_request_direction.selection__stock_request__direction__outbound +#: model:ir.model.fields.selection,name:stock_request_direction.selection__stock_request_order__direction__outbound +msgid "Outbound" +msgstr "In uscita" + +#. module: stock_request_direction +#: model:ir.model,name:stock_request_direction.model_stock_request +msgid "Stock Request" +msgstr "Richiesta di magazzino" + +#. module: stock_request_direction +#: model:ir.model,name:stock_request_direction.model_stock_request_order +msgid "Stock Request Order" +msgstr "Ordine richiesta di magazzino" diff --git a/stock_request_direction/i18n/stock_request_direction.pot b/stock_request_direction/i18n/stock_request_direction.pot new file mode 100644 index 00000000..fde96272 --- /dev/null +++ b/stock_request_direction/i18n/stock_request_direction.pot @@ -0,0 +1,60 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_request_direction +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.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_direction +#: model:ir.model.fields,field_description:stock_request_direction.field_stock_request__direction +#: model:ir.model.fields,field_description:stock_request_direction.field_stock_request_order__direction +msgid "Direction" +msgstr "" + +#. module: stock_request_direction +#: model:ir.model.fields,field_description:stock_request_direction.field_stock_request__display_name +#: model:ir.model.fields,field_description:stock_request_direction.field_stock_request_order__display_name +msgid "Display Name" +msgstr "" + +#. module: stock_request_direction +#: model:ir.model.fields,field_description:stock_request_direction.field_stock_request__id +#: model:ir.model.fields,field_description:stock_request_direction.field_stock_request_order__id +msgid "ID" +msgstr "" + +#. module: stock_request_direction +#: model:ir.model.fields.selection,name:stock_request_direction.selection__stock_request__direction__inbound +#: model:ir.model.fields.selection,name:stock_request_direction.selection__stock_request_order__direction__inbound +msgid "Inbound" +msgstr "" + +#. module: stock_request_direction +#: model:ir.model.fields,field_description:stock_request_direction.field_stock_request____last_update +#: model:ir.model.fields,field_description:stock_request_direction.field_stock_request_order____last_update +msgid "Last Modified on" +msgstr "" + +#. module: stock_request_direction +#: model:ir.model.fields.selection,name:stock_request_direction.selection__stock_request__direction__outbound +#: model:ir.model.fields.selection,name:stock_request_direction.selection__stock_request_order__direction__outbound +msgid "Outbound" +msgstr "" + +#. module: stock_request_direction +#: model:ir.model,name:stock_request_direction.model_stock_request +msgid "Stock Request" +msgstr "" + +#. module: stock_request_direction +#: model:ir.model,name:stock_request_direction.model_stock_request_order +msgid "Stock Request Order" +msgstr "" diff --git a/stock_request_direction/i18n/zh_CN.po b/stock_request_direction/i18n/zh_CN.po new file mode 100644 index 00000000..2648274f --- /dev/null +++ b/stock_request_direction/i18n/zh_CN.po @@ -0,0 +1,63 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_request_direction +# +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_direction +#: model:ir.model.fields,field_description:stock_request_direction.field_stock_request__direction +#: model:ir.model.fields,field_description:stock_request_direction.field_stock_request_order__direction +msgid "Direction" +msgstr "方向" + +#. module: stock_request_direction +#: model:ir.model.fields,field_description:stock_request_direction.field_stock_request__display_name +#: model:ir.model.fields,field_description:stock_request_direction.field_stock_request_order__display_name +msgid "Display Name" +msgstr "" + +#. module: stock_request_direction +#: model:ir.model.fields,field_description:stock_request_direction.field_stock_request__id +#: model:ir.model.fields,field_description:stock_request_direction.field_stock_request_order__id +msgid "ID" +msgstr "" + +#. module: stock_request_direction +#: model:ir.model.fields.selection,name:stock_request_direction.selection__stock_request__direction__inbound +#: model:ir.model.fields.selection,name:stock_request_direction.selection__stock_request_order__direction__inbound +msgid "Inbound" +msgstr "入库" + +#. module: stock_request_direction +#: model:ir.model.fields,field_description:stock_request_direction.field_stock_request____last_update +#: model:ir.model.fields,field_description:stock_request_direction.field_stock_request_order____last_update +msgid "Last Modified on" +msgstr "" + +#. module: stock_request_direction +#: model:ir.model.fields.selection,name:stock_request_direction.selection__stock_request__direction__outbound +#: model:ir.model.fields.selection,name:stock_request_direction.selection__stock_request_order__direction__outbound +msgid "Outbound" +msgstr "出库" + +#. module: stock_request_direction +#: model:ir.model,name:stock_request_direction.model_stock_request +msgid "Stock Request" +msgstr "库存请求" + +#. module: stock_request_direction +#: model:ir.model,name:stock_request_direction.model_stock_request_order +msgid "Stock Request Order" +msgstr "库存请求单" diff --git a/stock_request_direction/models/__init__.py b/stock_request_direction/models/__init__.py new file mode 100644 index 00000000..010f84b1 --- /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 00000000..96d7ad34 --- /dev/null +++ b/stock_request_direction/models/stock_request.py @@ -0,0 +1,24 @@ +# 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")], + states={"draft": [("readonly", False)]}, + readonly=True, + ) + + @api.onchange("direction") + def _onchange_location_id(self): + if not self._context.get("default_location_id"): + 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 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 00000000..720c3fbc --- /dev/null +++ b/stock_request_direction/models/stock_request_order.py @@ -0,0 +1,33 @@ +# 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")], + states={"draft": [("readonly", False)]}, + readonly=True, + ) + + @api.onchange("warehouse_id", "direction") + def _onchange_location_id(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 + for stock_request in self.stock_request_ids: + if stock_request.route_id: + stock_request.route_id = False + + def change_childs(self): + res = super().change_childs() + if not self._context.get("no_change_childs", False): + for line in self.stock_request_ids: + line.direction = self.direction + return res diff --git a/stock_request_direction/readme/CONTRIBUTORS.rst b/stock_request_direction/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..0499bf0f --- /dev/null +++ b/stock_request_direction/readme/CONTRIBUTORS.rst @@ -0,0 +1,13 @@ +* `Open Source Integrators `_ + + * Maxime Chambreuil + * Steve Campbell + * Freni Patel + +* `Ecosoft `__: + + * Pimolnat Suntian + * Kitti U. + +* `[APSL](https://apsl.tech)`__: + * Antoni Marroig \ No newline at end of file diff --git a/stock_request_direction/readme/DESCRIPTION.rst b/stock_request_direction/readme/DESCRIPTION.rst new file mode 100644 index 00000000..8620293b --- /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 00000000..22156f01 --- /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 00000000..c31ecfd9 Binary files /dev/null and b/stock_request_direction/static/description/icon.png differ diff --git a/stock_request_direction/static/description/index.html b/stock_request_direction/static/description/index.html new file mode 100644 index 00000000..a000cafa --- /dev/null +++ b/stock_request_direction/static/description/index.html @@ -0,0 +1,461 @@ + + + + + + +Stock Requests Direction + + + +
+

Stock Requests Direction

+ + +

Beta License: LGPL-3 OCA/stock-logistics-request Translate me on Weblate Try me on Runboat

+

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.

+

Table of contents

+ +
+

Usage

+
+

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.

+
+
+
+

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 to smash 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.

+

Current maintainer:

+

max3903

+

This module is part of the OCA/stock-logistics-request project on GitHub.

+

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

+
+
+
+ + diff --git a/stock_request_direction/tests/__init__.py b/stock_request_direction/tests/__init__.py new file mode 100644 index 00000000..0cce77bc --- /dev/null +++ b/stock_request_direction/tests/__init__.py @@ -0,0 +1 @@ +from . import test_stock_request_direction diff --git a/stock_request_direction/tests/test_stock_request_direction.py b/stock_request_direction/tests/test_stock_request_direction.py new file mode 100644 index 00000000..892948f4 --- /dev/null +++ b/stock_request_direction/tests/test_stock_request_direction.py @@ -0,0 +1,128 @@ +# Copyright 2017 ForgeFlow 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.test_stock_request import TestStockRequest + + +class TestStockRequestBase(TestStockRequest): + @classmethod + def setUpClass(cls): + super(TestStockRequestBase, cls).setUpClass() + + def test_onchange_direction_request(self): + # Outbound direction + vals = { + "product_id": self.product.id, + "product_uom_id": self.product.uom_id.id, + "product_uom_qty": 5.0, + } + stock_request = ( + self.stock_request.with_user(self.stock_request_user) + .with_context(company_id=self.main_company.id) + .create(vals) + ) + self.assertEqual(stock_request.location_id, self.warehouse.lot_stock_id) + stock_request.direction = "outbound" + stock_request._onchange_location_id() + self.assertEqual( + stock_request.location_id, + stock_request.company_id.partner_id.property_stock_customer, + ) + # Inbound direction + vals = { + "product_id": self.product.id, + "product_uom_id": self.product.uom_id.id, + "product_uom_qty": 5.0, + } + stock_request = ( + self.stock_request.with_user(self.stock_request_user) + .with_context(company_id=self.main_company.id) + .create(vals) + ) + self.assertEqual(stock_request.location_id, self.warehouse.lot_stock_id) + stock_request.direction = "inbound" + stock_request._onchange_location_id() + self.assertEqual( + stock_request.location_id, + stock_request.warehouse_id.lot_stock_id, + ) + + def test_onchange_direction_order(self): + expected_date = fields.Datetime.now() + # Outbound direction + vals = { + "company_id": self.main_company.id, + "warehouse_id": self.warehouse.id, + "location_id": self.warehouse.lot_stock_id.id, + "expected_date": expected_date, + "direction": "outbound", + "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.with_user(self.stock_request_user) + .with_context(company_id=self.main_company.id) + .create(vals) + ) + self.assertEqual(order.location_id, self.warehouse.lot_stock_id) + order.direction = "outbound" + order._onchange_location_id() + order.onchange_location_id() + self.assertEqual( + order.stock_request_ids[:1].location_id, + order.company_id.partner_id.property_stock_customer, + ) + # Inbound direction + vals = { + "company_id": self.main_company.id, + "warehouse_id": self.warehouse.id, + "location_id": self.warehouse.lot_stock_id.id, + "expected_date": expected_date, + "direction": "inbound", + "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.with_user(self.stock_request_user) + .with_context(company_id=self.main_company.id) + .create(vals) + ) + self.assertEqual(order.location_id, self.warehouse.lot_stock_id) + order.stock_request_ids[:1].route_id = self.route + order.direction = "inbound" + order._onchange_location_id() + order.onchange_location_id() + self.assertEqual( + order.stock_request_ids[:1].location_id, + order.warehouse_id.lot_stock_id, + ) + self.assertFalse(order.stock_request_ids[:1].route_id) 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 00000000..c9d9148f --- /dev/null +++ b/stock_request_direction/views/res_config_settings.xml @@ -0,0 +1,13 @@ + + + + + + + + + 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 00000000..5eefab6b --- /dev/null +++ b/stock_request_direction/views/stock_request_order_views.xml @@ -0,0 +1,39 @@ + + + + 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 00000000..5dd26be9 --- /dev/null +++ b/stock_request_direction/views/stock_request_views.xml @@ -0,0 +1,24 @@ + + + + stock.request.tree + stock.request + + + + + + + + + stock.request.form + stock.request + + + + + + + +