Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[17.0][MIG] stock_request_purchase: Migration to 17.0 #35

Merged
merged 34 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
f58bb52
OCA Transbot updated translations from Transifex
oca-transbot Dec 30, 2017
c35c29e
add stock_request in 11.0
JordiBForgeFlow Nov 13, 2017
de18c34
[IMP] stock_request_purchase: Remove hook
MiquelRForgeFlow Mar 19, 2018
c022e44
[IMP] stock_request_purchase: Add Stock request orders. Change logo
etobella Apr 10, 2018
8ac9e19
[FIX] Various fixes:
MiquelRForgeFlow Apr 11, 2018
6699d5b
various fixes
JordiBForgeFlow Apr 25, 2018
4c89654
[IMP] simplify queries
etobella Apr 27, 2018
99792bc
Translated using Weblate (Spanish)
etobella Sep 5, 2018
40cda91
[12.0][MIG] stock_request_purchase
kittiu Jun 26, 2019
9c27849
[FIX] stock_request_purchase: remove sudo
etobella Jul 15, 2019
d5d9802
[FIX] Dependencies
MiquelRForgeFlow Aug 12, 2019
d9184e4
[FIX] stock_request_*: add expected_date implicit on tests to avoid e…
HviorForgeFlow Aug 28, 2019
69054d3
Added translation using Weblate (Chinese (Simplified))
liweijie0812 Oct 16, 2019
9ea48d5
[12.0][FIX] Stock Request Order purchase button fix
Nov 13, 2019
f6e186c
Translated using Weblate (Spanish)
Jan 17, 2020
5b1adc7
[IMP] stock_request_purchase: black, isort
JoanSForgeFlow Mar 9, 2020
c345202
[MIG] stock_request_purchase: Migration to 13.0
JoanSForgeFlow Mar 9, 2020
b59b641
[UPD] Eficent -> ForgeFlow
MiquelRForgeFlow Sep 30, 2020
e37cca1
[IMP] stock_request_purchase: black, isort, prettier
alan196 Oct 12, 2020
8442598
[MIG] stock_request_purchase: Migration to 14.0
alan196 Oct 12, 2020
23e38a6
[14.0][IMP] stock_request_purchase: Use _for_xml_id for actions
rousseldenis Nov 24, 2021
128b368
[MIG] stock_request_purchase: Migration to 15.0
BernatPForgeFlow Jan 20, 2022
14712f3
[IMP] stock_request_purchase: Propagate the cancellation of related p…
victoralmau May 18, 2023
8810653
[IMP] stock_request_purchase: Change invisible attr of the action_vie…
victoralmau Aug 28, 2023
b8bf7d1
[IMP] stock_request_purchase: Add _get_stock_requests() method to get…
victoralmau Aug 28, 2023
5a4da64
[FIX] stock_request_purchase: Change to the correct icon
victoralmau Sep 11, 2023
aace9b2
Translated using Weblate (Spanish)
Ivorra78 Oct 15, 2023
e91b544
Added translation using Weblate (Italian)
mymage Dec 15, 2023
3b01127
[IMP] stock_request_purchase: pre-commit stuff
victoralmau Mar 27, 2024
2b8684b
[MIG] stock_request_purchase: Migration to 16.0
bruno-zanotti Mar 22, 2024
0ced3c0
[UPD] Update stock_request_purchase.pot
Mar 27, 2024
33d60d8
[IMP] stock_request_purchase: pre-commit execution
ced-adhoc Jul 8, 2024
f90147d
[17.0][MIG] stock_request_purchase: Migration to 17.0
ced-adhoc Jul 8, 2024
5244df8
[17.0][FIX] stock_request: setUp() to setUpClass()
ced-adhoc Jul 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
219 changes: 107 additions & 112 deletions stock_request/tests/test_stock_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,153 +8,150 @@
from odoo import exceptions, fields
from odoo.tests import common, new_test_user

from odoo.addons.base.tests.common import BaseCommon


class TestStockRequest(BaseCommon):
@classmethod
def setUpClass(cls):
super().setUpClass()

class TestStockRequest(common.TransactionCase):
def setUp(self):
super().setUp()
self.env = self.env(
context=dict(
self.env.context,
mail_create_nolog=True,
mail_create_nosubscribe=True,
mail_notrack=True,
no_reset_password=True,
tracking_disable=True,
)
)
# 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.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.virtual_loc = self.env.ref("stock.stock_location_customers")
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.virtual_loc = cls.env.ref("stock.stock_location_customers")
# common data
self.company_2 = self.env["res.company"].create(
{"name": "Comp2", "parent_id": self.main_company.id}
cls.company_2 = cls.env["res.company"].create(
{"name": "Comp2", "parent_id": cls.main_company.id}
)
self.company_2_address = (
self.env["res.partner"]
.with_context(company_id=self.company_2.id)
cls.company_2_address = (
cls.env["res.partner"]
.with_context(company_id=cls.company_2.id)
.create({"name": "Peñiscola"})
)
self.wh2 = self.env["stock.warehouse"].search(
[("company_id", "=", self.company_2.id)], limit=1
cls.wh2 = cls.env["stock.warehouse"].search(
[("company_id", "=", cls.company_2.id)], limit=1
)
self.stock_request_user = new_test_user(
self.env,
cls.stock_request_user = new_test_user(
cls.env,
login="stock_request_user",
groups="stock_request.group_stock_request_user",
company_ids=[(6, 0, [self.main_company.id, self.company_2.id])],
company_ids=[(4, cls.main_company.id), (4, cls.company_2.id)],
)
self.stock_request_manager = new_test_user(
self.env,
cls.stock_request_manager = new_test_user(
cls.env,
login="stock_request_manager",
groups="stock_request.group_stock_request_manager",
company_ids=[(6, 0, [self.main_company.id, self.company_2.id])],
)
self.product = self._create_product("SH", "Shoes", False)
self.product_company_2 = self._create_product(
"SH_2", "Shoes", self.company_2.id
company_ids=[(4, cls.main_company.id), (4, cls.company_2.id)],
)
self.ressuply_loc = self._create_location(
cls.product = cls._create_product("SH", "Shoes", False)
cls.product_company_2 = cls._create_product("SH_2", "Shoes", cls.company_2.id)

cls.ressuply_loc = cls._create_location(
name="Ressuply",
location_id=self.warehouse.view_location_id.id,
company_id=self.main_company.id,
location_id=cls.warehouse.view_location_id.id,
company_id=cls.main_company.id,
)
self.ressuply_loc_2 = self._create_location(
cls.ressuply_loc_2 = cls._create_location(
name="Ressuply",
location_id=self.wh2.view_location_id.id,
company_id=self.company_2.id,
location_id=cls.wh2.view_location_id.id,
company_id=cls.company_2.id,
)
self.route = self._create_location_route(
name="Transfer", company_id=self.main_company.id
)
self.route_2 = self._create_location_route(
name="Transfer", company_id=self.company_2.id
)
self.route_3 = self._create_location_route(
name="Transfer", company_id=self.main_company.id
)
self.uom_dozen = self.env["uom.uom"].create(

cls.route = cls._create_route(name="Transfer", company_id=cls.main_company.id)
cls.route_2 = cls._create_route(name="Transfer", company_id=cls.company_2.id)
cls.route_3 = cls._create_route(name="Transfer", company_id=cls.main_company.id)
cls.uom_dozen = cls.env["uom.uom"].create(
{
"name": "Test-DozenA",
"category_id": self.categ_unit.id,
"category_id": cls.categ_unit.id,
"factor_inv": 12,
"uom_type": "bigger",
"rounding": 0.001,
}
)
self.env["stock.rule"].create(

cls.env["stock.rule"].create(
{
"name": "Transfer",
"route_id": self.route.id,
"location_src_id": self.ressuply_loc.id,
"location_dest_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["stock.rule"].create(

cls.env["stock.rule"].create(
{
"name": "Transfer",
"route_id": self.route_2.id,
"location_src_id": self.ressuply_loc_2.id,
"location_dest_id": self.wh2.lot_stock_id.id,
"route_id": cls.route_2.id,
"location_src_id": cls.ressuply_loc_2.id,
"location_dest_id": cls.wh2.lot_stock_id.id,
"action": "pull",
"picking_type_id": self.wh2.int_type_id.id,
"picking_type_id": cls.wh2.int_type_id.id,
"procure_method": "make_to_stock",
"warehouse_id": self.wh2.id,
"company_id": self.company_2.id,
"warehouse_id": cls.wh2.id,
"company_id": cls.company_2.id,
}
)
self.env["ir.config_parameter"].sudo().set_param(

cls.env["ir.config_parameter"].sudo().set_param(
"stock.no_auto_scheduler", "True"
)

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,
detailed_type="product",
type="product",
**vals,
)
)

@classmethod
def _create_product_template_attribute_line(
self, product_tmpl_id, attribute_id, value_id
cls, product_tmpl_id, attribute_id, value_id
):
return self.env["product.template.attribute.line"].create(
return cls.env["product.template.attribute.line"].create(
{
"product_tmpl_id": product_tmpl_id,
"attribute_id": attribute_id,
"value_ids": value_id,
}
)

def _create_product_attribute_value(self, name, attribute):
return self.env["product.attribute.value"].create(
@classmethod
def _create_product_attribute_value(cls, name, attribute):
return cls.env["product.attribute.value"].create(
{"name": name, "attribute_id": attribute}
)

def _create_product_attribute(self, name):
return self.env["product.attribute"].create({"name": name})
@classmethod
def _create_product_attribute(cls, name):
return cls.env["product.attribute"].create({"name": name})

def _create_location(self, **vals):
return self.env["stock.location"].create(dict(usage="internal", **vals))
@classmethod
def _create_location(cls, **vals):
return cls.env["stock.location"].create(dict(usage="internal", **vals))

def _create_location_route(self, **vals):
return self.env["stock.route"].create(
@classmethod
def _create_route(cls, **vals):
return cls.env["stock.route"].create(
dict(
product_categ_selectable=False,
product_selectable=True,
Expand All @@ -165,9 +162,6 @@ def _create_location_route(self, **vals):


class TestStockRequestBase(TestStockRequest):
def setUp(self):
super().setUp()

def _create_stock_quant(self, product, location, qty):
self.env["stock.quant"].create(
{"product_id": product.id, "location_id": location.id, "quantity": qty}
Expand Down Expand Up @@ -1252,61 +1246,62 @@ def test_cancellation(self):


class TestStockRequestOrderState(TestStockRequest):
def setUp(self):
super().setUp()
self.product_a = self._create_product(
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.product_a = cls._create_product(
"CODEA",
"Product A",
self.main_company.id,
cls.main_company.id,
)
self.product_a.route_ids = [(6, 0, self.route.ids)]
self.product_b = self._create_product(
cls.product_a.route_ids = [(6, 0, cls.route.ids)]
cls.product_b = cls._create_product(
"CODEB",
"Product B",
self.main_company.id,
cls.main_company.id,
)
self.product_b.route_ids = [(6, 0, self.route.ids)]
cls.product_b.route_ids = [(6, 0, cls.route.ids)]
expected_date = fields.Datetime.now()
vals = {
"company_id": self.main_company.id,
"warehouse_id": self.warehouse.id,
"location_id": self.warehouse.lot_stock_id.id,
"company_id": cls.main_company.id,
"warehouse_id": cls.warehouse.id,
"location_id": cls.warehouse.lot_stock_id.id,
"expected_date": expected_date,
"stock_request_ids": [
(
0,
0,
{
"product_id": self.product_a.id,
"product_uom_id": self.product_a.uom_id.id,
"product_id": cls.product_a.id,
"product_uom_id": cls.product_a.uom_id.id,
"product_uom_qty": 1.0,
"company_id": self.main_company.id,
"warehouse_id": self.warehouse.id,
"location_id": self.warehouse.lot_stock_id.id,
"company_id": cls.main_company.id,
"warehouse_id": cls.warehouse.id,
"location_id": cls.warehouse.lot_stock_id.id,
"expected_date": expected_date,
},
),
(
0,
0,
{
"product_id": self.product_b.id,
"product_uom_id": self.product_b.uom_id.id,
"product_id": cls.product_b.id,
"product_uom_id": cls.product_b.uom_id.id,
"product_uom_qty": 1.0,
"company_id": self.main_company.id,
"warehouse_id": self.warehouse.id,
"location_id": self.warehouse.lot_stock_id.id,
"company_id": cls.main_company.id,
"warehouse_id": cls.warehouse.id,
"location_id": cls.warehouse.lot_stock_id.id,
"expected_date": expected_date,
},
),
],
}
self.order = self.request_order.new(vals)
self.request_a = self.order.stock_request_ids.filtered(
lambda x: x.product_id == self.product_a
cls.order = cls.request_order.create(vals)
cls.request_a = cls.order.stock_request_ids.filtered(
lambda x: x.product_id == cls.product_a
)
self.request_b = self.order.stock_request_ids.filtered(
lambda x: x.product_id == self.product_b
cls.request_b = cls.order.stock_request_ids.filtered(
lambda x: x.product_id == cls.product_b
)

def test_stock_request_order_state_01(self):
Expand Down
Loading
Loading