[MIG][14.0] stock_available_base_exclude_location

This commit is contained in:
xavier-bouquiaux
2021-06-23 10:25:12 +02:00
committed by Xavier Bouquiaux
parent b1cd0675c2
commit aa2dfe06fe
8 changed files with 24 additions and 13 deletions

View File

@@ -1 +0,0 @@
__import__('pkg_resources').declare_namespace(__name__)

View File

@@ -1 +0,0 @@
__import__('pkg_resources').declare_namespace(__name__)

View File

@@ -5,7 +5,7 @@
"name": "Stock Available Base Exclude Location", "name": "Stock Available Base Exclude Location",
"summary": """ "summary": """
Base module to exclude locations for product available quantities""", Base module to exclude locations for product available quantities""",
"version": "10.0.1.0.1", "version": "14.0.1.0.0",
"category": "Warehouse", "category": "Warehouse",
"maintainers": ["rousseldenis"], "maintainers": ["rousseldenis"],
"license": "AGPL-3", "license": "AGPL-3",

View File

@@ -18,9 +18,11 @@ class ProductProduct(models.Model):
:param compute_child: :param compute_child:
:return: :return:
""" """
domain_quant_loc, domain_move_in_loc, domain_move_out_loc = super( (
ProductProduct, self domain_quant_loc,
)._get_domain_locations_new( domain_move_in_loc,
domain_move_out_loc,
) = super()._get_domain_locations_new(
location_ids=location_ids, location_ids=location_ids,
company_id=company_id, company_id=company_id,
compute_child=compute_child, compute_child=compute_child,
@@ -35,7 +37,13 @@ class ProductProduct(models.Model):
) )
domain_move_in_loc = expression.AND( 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, domain_quant_loc,
] ]
) )

View File

@@ -7,6 +7,9 @@ from odoo import fields, models
class StockExcludeLocationMixin(models.AbstractModel): class StockExcludeLocationMixin(models.AbstractModel):
_name = "stock.exclude.location.mixin" _name = "stock.exclude.location.mixin"
_description = (
"technical base module to allow defining excluded locations on an Odoo model"
)
stock_excluded_location_ids = fields.Many2many( stock_excluded_location_ids = fields.Many2many(
comodel_name="stock.location", comodel_name="stock.location",

View File

@@ -1 +1,2 @@
* Denis Roussel <denis.roussel@acsone.eu> * Denis Roussel <denis.roussel@acsone.eu>
* Xavier Bouquiaux <xavier.bouquiaux@acsone.eu>

View File

@@ -16,7 +16,7 @@ class TestExcludeLocation(SavepointCase):
cls.loader.update_registry((ResPartner,)) cls.loader.update_registry((ResPartner,))
cls.fake = cls.env["res.partner"].create({"name": "name"}) 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"} 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 = cls.env["stock.location"].create(vals)
cls.sub_location_1._parent_store_compute() cls.sub_location_1._parent_store_compute()
@@ -33,14 +33,13 @@ class TestExcludeLocation(SavepointCase):
:param product: product.product recordset :param product: product.product recordset
:param qty: float :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, "product_id": product.id,
"new_quantity": qty,
"location_id": location.id, "location_id": location.id,
"inventory_quantity": qty,
} }
) )
wizard.change_product_qty()
def test_exclude_location(self): def test_exclude_location(self):
# Add different levels of stock for product as : # Add different levels of stock for product as :
@@ -54,6 +53,7 @@ class TestExcludeLocation(SavepointCase):
qty = self.product.with_context( qty = self.product.with_context(
excluded_location_ids=self.fake.stock_excluded_location_ids excluded_location_ids=self.fake.stock_excluded_location_ids
).qty_available ).qty_available
self.assertEquals(50.0, qty) self.assertEqual(50.0, qty)
self.product.invalidate_cache()
qty = self.product.qty_available qty = self.product.qty_available
self.assertEquals(75.0, qty) self.assertEqual(75.0, qty)

1
test-requirements.txt Normal file
View File

@@ -0,0 +1 @@
odoo_test_helper