Skip to content

Commit

Permalink
[MIG] stock_request_picking_type: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
peluko00 committed May 8, 2024
1 parent 2f705fd commit eee1a16
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 127 deletions.
4 changes: 3 additions & 1 deletion stock_request_picking_type/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:ee0387a8e3d70bf7530fc83806d909ec62acee57d096d589d1b8c3afb1ca8b2a
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down Expand Up @@ -66,6 +66,8 @@ Contributors
* Maxime Chambreuil <mchambreuil@opensourceintegrators.com>
* Pimolnat Suntian <pimolnats@ecosoft.co.th>
* Raphael Lee <rlee@opensourceintegrators.com>
* [APSL](https://apsl.tech):
* Antoni Marroig <amarroig@apsl.net>

Maintainers
~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion stock_request_picking_type/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down
16 changes: 0 additions & 16 deletions stock_request_picking_type/migrations/12.0.2.0.0/post-migration.py

This file was deleted.

2 changes: 2 additions & 0 deletions stock_request_picking_type/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
* Maxime Chambreuil <mchambreuil@opensourceintegrators.com>
* Pimolnat Suntian <pimolnats@ecosoft.co.th>
* Raphael Lee <rlee@opensourceintegrators.com>
* [APSL](https://apsl.tech):
* Antoni Marroig <amarroig@apsl.net>
4 changes: 3 additions & 1 deletion stock_request_picking_type/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Stock Request Picking Type</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:d1fd32d3de59cc5caa70018b4d2a579ee2af8c28c01a8e896149243576a14abf
!! source digest: sha256:ee0387a8e3d70bf7530fc83806d909ec62acee57d096d589d1b8c3afb1ca8b2a
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/stock-logistics-request/tree/16.0/stock_request_picking_type"><img alt="OCA/stock-logistics-request" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--request-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/stock-logistics-request-16-0/stock-logistics-request-16-0-stock_request_picking_type"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-request&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module adds stock request orders within the Inventory app with a new operation type.</p>
Expand Down Expand Up @@ -414,6 +414,8 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<li>Maxime Chambreuil &lt;<a class="reference external" href="mailto:mchambreuil&#64;opensourceintegrators.com">mchambreuil&#64;opensourceintegrators.com</a>&gt;</li>
<li>Pimolnat Suntian &lt;<a class="reference external" href="mailto:pimolnats&#64;ecosoft.co.th">pimolnats&#64;ecosoft.co.th</a>&gt;</li>
<li>Raphael Lee &lt;<a class="reference external" href="mailto:rlee&#64;opensourceintegrators.com">rlee&#64;opensourceintegrators.com</a>&gt;</li>
<li>[APSL](<a class="reference external" href="https://apsl.tech">https://apsl.tech</a>):
* Antoni Marroig &lt;<a class="reference external" href="mailto:amarroig&#64;apsl.net">amarroig&#64;apsl.net</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
118 changes: 61 additions & 57 deletions stock_request_picking_type/tests/test_stock_picking_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
107 changes: 56 additions & 51 deletions stock_request_picking_type/tests/test_stock_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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()
Expand Down Expand Up @@ -156,16 +159,18 @@ def test_create(self):
],
}

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],
warehouse_id=self.warehouse.id,
location_id=self.warehouse.lot_stock_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)
Expand All @@ -185,4 +190,4 @@ def test_create(self):
order = self.request_order.with_user(self.stock_request_user).create(order_vals)

# test create()
self.assertEqual(order.picking_type_id, new_pick_type)
self.assertNotEqual(order.picking_type_id, new_pick_type)

0 comments on commit eee1a16

Please sign in to comment.