mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[MIG][14.0] stock_available_base_exclude_location
This commit is contained in:
committed by
Xavier Bouquiaux
parent
b1cd0675c2
commit
aa2dfe06fe
@@ -5,7 +5,7 @@
|
||||
"name": "Stock Available Base Exclude Location",
|
||||
"summary": """
|
||||
Base module to exclude locations for product available quantities""",
|
||||
"version": "10.0.1.0.1",
|
||||
"version": "14.0.1.0.0",
|
||||
"category": "Warehouse",
|
||||
"maintainers": ["rousseldenis"],
|
||||
"license": "AGPL-3",
|
||||
|
||||
@@ -18,9 +18,11 @@ class ProductProduct(models.Model):
|
||||
:param compute_child:
|
||||
:return:
|
||||
"""
|
||||
domain_quant_loc, domain_move_in_loc, domain_move_out_loc = super(
|
||||
ProductProduct, self
|
||||
)._get_domain_locations_new(
|
||||
(
|
||||
domain_quant_loc,
|
||||
domain_move_in_loc,
|
||||
domain_move_out_loc,
|
||||
) = super()._get_domain_locations_new(
|
||||
location_ids=location_ids,
|
||||
company_id=company_id,
|
||||
compute_child=compute_child,
|
||||
@@ -35,7 +37,13 @@ class ProductProduct(models.Model):
|
||||
)
|
||||
domain_move_in_loc = expression.AND(
|
||||
[
|
||||
[("location_dest_id", "not in", excluded_location_ids.ids)],
|
||||
[
|
||||
(
|
||||
"location_dest_id",
|
||||
"not in",
|
||||
excluded_location_ids.ids,
|
||||
)
|
||||
],
|
||||
domain_quant_loc,
|
||||
]
|
||||
)
|
||||
|
||||
@@ -7,6 +7,9 @@ from odoo import fields, models
|
||||
class StockExcludeLocationMixin(models.AbstractModel):
|
||||
|
||||
_name = "stock.exclude.location.mixin"
|
||||
_description = (
|
||||
"technical base module to allow defining excluded locations on an Odoo model"
|
||||
)
|
||||
|
||||
stock_excluded_location_ids = fields.Many2many(
|
||||
comodel_name="stock.location",
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
* Denis Roussel <denis.roussel@acsone.eu>
|
||||
* Xavier Bouquiaux <xavier.bouquiaux@acsone.eu>
|
||||
|
||||
@@ -16,7 +16,7 @@ class TestExcludeLocation(SavepointCase):
|
||||
cls.loader.update_registry((ResPartner,))
|
||||
|
||||
cls.fake = cls.env["res.partner"].create({"name": "name"})
|
||||
cls.location_shop = cls.env.ref("stock.stock_location_shop0")
|
||||
cls.location_shop = cls.env.ref("stock.stock_location_stock")
|
||||
vals = {"location_id": cls.location_shop.id, "name": "Sub Location 1"}
|
||||
cls.sub_location_1 = cls.env["stock.location"].create(vals)
|
||||
cls.sub_location_1._parent_store_compute()
|
||||
@@ -33,14 +33,13 @@ class TestExcludeLocation(SavepointCase):
|
||||
:param product: product.product recordset
|
||||
:param qty: float
|
||||
"""
|
||||
wizard = self.env["stock.change.product.qty"].create(
|
||||
self.env["stock.quant"].with_context(inventory_mode=True).create(
|
||||
{
|
||||
"product_id": product.id,
|
||||
"new_quantity": qty,
|
||||
"location_id": location.id,
|
||||
"inventory_quantity": qty,
|
||||
}
|
||||
)
|
||||
wizard.change_product_qty()
|
||||
|
||||
def test_exclude_location(self):
|
||||
# Add different levels of stock for product as :
|
||||
@@ -54,6 +53,7 @@ class TestExcludeLocation(SavepointCase):
|
||||
qty = self.product.with_context(
|
||||
excluded_location_ids=self.fake.stock_excluded_location_ids
|
||||
).qty_available
|
||||
self.assertEquals(50.0, qty)
|
||||
self.assertEqual(50.0, qty)
|
||||
self.product.invalidate_cache()
|
||||
qty = self.product.qty_available
|
||||
self.assertEquals(75.0, qty)
|
||||
self.assertEqual(75.0, qty)
|
||||
|
||||
Reference in New Issue
Block a user