diff --git a/stock_request_picking_type/README.rst b/stock_request_picking_type/README.rst index 02e73a1c..13b9b257 100644 --- a/stock_request_picking_type/README.rst +++ b/stock_request_picking_type/README.rst @@ -7,7 +7,7 @@ Stock Request Picking Type !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:d1fd32d3de59cc5caa70018b4d2a579ee2af8c28c01a8e896149243576a14abf + !! source digest: sha256:ee201635a3febbcba6e6023c0a23b866ec29c66e143a839b7bd41970e6a2ce46 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png @@ -66,6 +66,8 @@ Contributors * Maxime Chambreuil * Pimolnat Suntian * Raphael Lee +* [APSL-Nagarro](https://apsl.tech): + * Antoni Marroig Maintainers ~~~~~~~~~~~ diff --git a/stock_request_picking_type/__manifest__.py b/stock_request_picking_type/__manifest__.py index a02d5791..21ce674f 100644 --- a/stock_request_picking_type/__manifest__.py +++ b/stock_request_picking_type/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Stock Request Picking Type", "summary": "Add Stock Requests to the Inventory App", - "version": "14.0.1.1.0", + "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)", diff --git a/stock_request_picking_type/migrations/12.0.2.0.0/post-migration.py b/stock_request_picking_type/migrations/12.0.2.0.0/post-migration.py deleted file mode 100644 index 1e5b9e6e..00000000 --- a/stock_request_picking_type/migrations/12.0.2.0.0/post-migration.py +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright (C) 2019 Open Source Integrators -# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). - - -def migrate(env, version): - if not version: - return - - env.execute( - "UPDATE stock_request_order " - "SET picking_type_id = (" - "SELECT id " - "FROM stock_picking_type " - "WHERE code = 'stock_request_order') " - "WHERE picking_type_id IS NULL;" - ) diff --git a/stock_request_picking_type/readme/CONTRIBUTORS.rst b/stock_request_picking_type/readme/CONTRIBUTORS.rst index e2a84a06..6e417c51 100644 --- a/stock_request_picking_type/readme/CONTRIBUTORS.rst +++ b/stock_request_picking_type/readme/CONTRIBUTORS.rst @@ -1,3 +1,5 @@ * Maxime Chambreuil * Pimolnat Suntian * Raphael Lee +* [APSL-Nagarro](https://apsl.tech): + * Antoni Marroig diff --git a/stock_request_picking_type/static/description/index.html b/stock_request_picking_type/static/description/index.html index 259d4385..fbfb45ea 100644 --- a/stock_request_picking_type/static/description/index.html +++ b/stock_request_picking_type/static/description/index.html @@ -367,7 +367,7 @@

Stock Request Picking Type

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:d1fd32d3de59cc5caa70018b4d2a579ee2af8c28c01a8e896149243576a14abf +!! source digest: sha256:ee201635a3febbcba6e6023c0a23b866ec29c66e143a839b7bd41970e6a2ce46 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

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

This module adds stock request orders within the Inventory app with a new operation type.

@@ -414,6 +414,8 @@

Contributors

  • Maxime Chambreuil <mchambreuil@opensourceintegrators.com>
  • Pimolnat Suntian <pimolnats@ecosoft.co.th>
  • Raphael Lee <rlee@opensourceintegrators.com>
  • +
  • [APSL-Nagarro](https://apsl.tech): +* Antoni Marroig <amarroig@apsl.net>
  • diff --git a/stock_request_picking_type/tests/test_stock_picking_type.py b/stock_request_picking_type/tests/test_stock_picking_type.py index 89813dc9..0f6db80b 100644 --- a/stock_request_picking_type/tests/test_stock_picking_type.py +++ b/stock_request_picking_type/tests/test_stock_picking_type.py @@ -8,103 +8,107 @@ class TestStockRequest(common.TransactionCase): - def setUp(self): - super(TestStockRequest, self).setUp() + @classmethod + def _create_user(cls, name, group_ids, company_ids): + return ( + cls.env["res.users"] + .with_context(**{"no_reset_password": True}) + .create( + { + "name": name, + "password": "demo", + "login": name, + "email": "@".join([name, "test.com"]), + "groups_id": [(6, 0, group_ids)], + "company_ids": [(6, 0, company_ids)], + } + ) + ) + + @classmethod + def _create_product(cls, default_code, name, company_id, **vals): + return cls.env["product.product"].create( + dict( + name=name, + default_code=default_code, + uom_id=cls.env.ref("uom.product_uom_unit").id, + company_id=company_id, + type="product", + **vals + ) + ) + + @classmethod + def setUpClass(cls): + super().setUpClass() # common models - self.stock_request = self.env["stock.request"] - self.request_order = self.env["stock.request.order"] + cls.stock_request = cls.env["stock.request"] + cls.request_order = cls.env["stock.request.order"] # refs - self.stock_request_user_group = self.env.ref( + cls.stock_request_user_group = cls.env.ref( "stock_request.group_stock_request_user" ) - self.stock_request_manager_group = self.env.ref( + cls.stock_request_manager_group = cls.env.ref( "stock_request.group_stock_request_manager" ) - self.main_company = self.env.ref("base.main_company") - self.warehouse = self.env.ref("stock.warehouse0") - self.categ_unit = self.env.ref("uom.product_uom_categ_unit") - self.default_picking_type = self.env.ref( + cls.main_company = cls.env.ref("base.main_company") + cls.warehouse = cls.env.ref("stock.warehouse0") + cls.categ_unit = cls.env.ref("uom.product_uom_categ_unit") + cls.default_picking_type = cls.env.ref( "stock_request_picking_type.stock_request_order" ) - self.product = self._create_product("SH", "Shoes", False) - self.stock_request_manager = self._create_user( + cls.product = cls._create_product("Shoes", "SH", False) + cls.stock_request_manager = cls._create_user( "stock_request_manager", - [self.stock_request_manager_group.id], - [self.main_company.id], + [cls.stock_request_manager_group.id], + [cls.main_company.id], ) - self.ressuply_loc = self.env["stock.location"].create( + cls.ressuply_loc = cls.env["stock.location"].create( { "name": "Ressuply", - "location_id": self.warehouse.view_location_id.id, + "location_id": cls.warehouse.view_location_id.id, "usage": "internal", - "company_id": self.main_company.id, + "company_id": cls.main_company.id, } ) - self.route = self.env["stock.location.route"].create( + cls.route = cls.env["stock.route"].create( { "name": "Transfer", "product_categ_selectable": False, "product_selectable": True, - "company_id": self.main_company.id, + "company_id": cls.main_company.id, "sequence": 10, } ) - self.rule = self.env["stock.rule"].create( + cls.rule = cls.env["stock.rule"].create( { "name": "Transfer", - "route_id": self.route.id, - "location_src_id": self.ressuply_loc.id, - "location_id": self.warehouse.lot_stock_id.id, + "route_id": cls.route.id, + "location_src_id": cls.ressuply_loc.id, + "location_dest_id": cls.warehouse.lot_stock_id.id, "action": "pull", - "picking_type_id": self.warehouse.int_type_id.id, + "picking_type_id": cls.warehouse.int_type_id.id, "procure_method": "make_to_stock", - "warehouse_id": self.warehouse.id, - "company_id": self.main_company.id, + "warehouse_id": cls.warehouse.id, + "company_id": cls.main_company.id, } ) - self.env["ir.config_parameter"].sudo().set_param( + cls.env["ir.config_parameter"].sudo().set_param( "stock.no_auto_scheduler", "True" ) - def _create_user(self, name, group_ids, company_ids): - return ( - self.env["res.users"] - .with_context({"no_reset_password": True}) - .create( - { - "name": name, - "password": "demo", - "login": name, - "email": "@".join([name, "test.com"]), - "groups_id": [(6, 0, group_ids)], - "company_ids": [(6, 0, company_ids)], - } - ) - ) - - def _create_product(self, default_code, name, company_id, **vals): - return self.env["product.product"].create( - dict( - name=name, - default_code=default_code, - uom_id=self.env.ref("uom.product_uom_unit").id, - company_id=company_id, - type="product", - **vals - ) - ) - class TestStockPickingType(TestStockRequest): - def setUp(self): - super(TestStockPickingType, self).setUp() + @classmethod + def setUpClass(cls): + super().setUpClass() def test_compute_sr_count(self): expected_date = fields.Datetime.now() diff --git a/stock_request_picking_type/tests/test_stock_request.py b/stock_request_picking_type/tests/test_stock_request.py index b8d106c1..09ad3bd7 100644 --- a/stock_request_picking_type/tests/test_stock_request.py +++ b/stock_request_picking_type/tests/test_stock_request.py @@ -7,46 +7,11 @@ class TestStockRequest(common.TransactionCase): - def setUp(self): - super(TestStockRequest, self).setUp() - - # common models - self.stock_request = self.env["stock.request"] - self.request_order = self.env["stock.request.order"] - - # refs - self.stock_request_user_group = self.env.ref( - "stock_request.group_stock_request_user" - ) - self.main_company = self.env.ref("base.main_company") - self.warehouse = self.env.ref("stock.warehouse0") - self.default_picking_type = self.env.ref( - "stock_request_picking_type.stock_request_order" - ) - - # common data - self.company_2 = self.env["res.company"].create( - {"name": "Comp2", "parent_id": self.main_company.id} - ) - self.company_2_address = ( - self.env["res.partner"] - .with_context(company_id=self.company_2.id) - .create({"name": "PeƱiscola"}) - ) - self.product = self._create_product("SH", "Shoes", False) - self.product_company_2 = self._create_product( - "SH_2", "Shoes", self.company_2.id - ) - self.stock_request_user = self._create_user( - "stock_request_user", - [self.stock_request_user_group.id], - [self.main_company.id, self.company_2.id], - ) - - def _create_user(self, name, group_ids, company_ids): + @classmethod + def _create_user(cls, name, group_ids, company_ids): return ( - self.env["res.users"] - .with_context({"no_reset_password": True}) + cls.env["res.users"] + .with_context(no_reset_password=True) .create( { "name": name, @@ -59,22 +24,60 @@ def _create_user(self, name, group_ids, company_ids): ) ) - def _create_product(self, default_code, name, company_id, **vals): - return self.env["product.product"].create( + @classmethod + def _create_product(cls, default_code, name, company_id, **vals): + return cls.env["product.product"].create( dict( name=name, default_code=default_code, - uom_id=self.env.ref("uom.product_uom_unit").id, + uom_id=cls.env.ref("uom.product_uom_unit").id, company_id=company_id, type="product", **vals ) ) + @classmethod + def setUpClass(cls): + super().setUpClass() + + # common models + cls.stock_request = cls.env["stock.request"] + cls.request_order = cls.env["stock.request.order"] + + # refs + cls.stock_request_user_group = cls.env.ref( + "stock_request.group_stock_request_user" + ) + cls.main_company = cls.env.ref("base.main_company") + cls.warehouse = cls.env.ref("stock.warehouse0") + cls.default_picking_type = cls.env.ref( + "stock_request_picking_type.stock_request_order" + ) + + # common data + cls.company_2 = cls.env["res.company"].create( + {"name": "Comp2", "parent_id": cls.main_company.id} + ) + cls.company_2_address = ( + cls.env["res.partner"] + .with_context(company_id=cls.company_2.id) + .create({"name": "PeƱiscola"}) + ) + + cls.product = cls._create_product("SH", "Shoes", False) + cls.product_company_2 = cls._create_product("SH_2", "Shoes", cls.company_2.id) + cls.stock_request_user = cls._create_user( + "stock_request_user", + [cls.stock_request_user_group.id], + [cls.main_company.id, cls.company_2.id], + ) + class TestStockRequestOrder(TestStockRequest): - def setUp(self): - super(TestStockRequestOrder, self).setUp() + @classmethod + def setUpClass(cls): + super().setUpClass() def test_onchanges_order(self): expected_date = fields.Datetime.now() @@ -134,55 +137,10 @@ def test_onchanges_order(self): def test_create(self): expected_date = fields.Datetime.now() - order_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, - }, - ) - ], - } - - form = Form(self.env["stock.request.order"]) - form.company_id = self.main_company + form = Form( + self.request_order.with_context(allowed_company_ids=[self.main_company.id]) + ) form.expected_date = expected_date - # test _getdefault_picking_type() + # # test _getdefault_picking_type() self.assertEqual(form.picking_type_id, self.default_picking_type) - - form.warehouse_id = self.warehouse - form.location_id = self.warehouse.lot_stock_id - - new_pick_type = ( - self.env["stock.picking.type"] - .with_context(company_id=self.main_company.id) - .create( - { - "name": "Stock Request wh", - "sequence_id": self.env.ref( - "stock_request.seq_stock_request_order" - ).id, - "code": "stock_request_order", - "sequence_code": "SRO", - "warehouse_id": self.warehouse.id, - } - ) - ) - - order = self.request_order.with_user(self.stock_request_user).create(order_vals) - - # test create() - self.assertEqual(order.picking_type_id, new_pick_type)