mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[IMP] stock_available_base_exclude_location: black, isort, prettier
This commit is contained in:
committed by
Xavier Bouquiaux
parent
21e3db5628
commit
b1cd0675c2
@@ -0,0 +1 @@
|
||||
__import__('pkg_resources').declare_namespace(__name__)
|
||||
@@ -0,0 +1 @@
|
||||
__import__('pkg_resources').declare_namespace(__name__)
|
||||
@@ -0,0 +1 @@
|
||||
../../../../stock_available_base_exclude_location
|
||||
6
setup/stock_available_base_exclude_location/setup.py
Normal file
6
setup/stock_available_base_exclude_location/setup.py
Normal file
@@ -0,0 +1,6 @@
|
||||
import setuptools
|
||||
|
||||
setuptools.setup(
|
||||
setup_requires=['setuptools-odoo'],
|
||||
odoo_addon=True,
|
||||
)
|
||||
@@ -1,18 +1,15 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2020 ACSONE SA/NV
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
{
|
||||
'name': 'Stock Available Base Exclude Location',
|
||||
'summary': """
|
||||
"name": "Stock Available Base Exclude Location",
|
||||
"summary": """
|
||||
Base module to exclude locations for product available quantities""",
|
||||
'version': '10.0.1.0.1',
|
||||
'category': 'Warehouse',
|
||||
'maintainers': ['rousseldenis'],
|
||||
'license': 'AGPL-3',
|
||||
'author': 'ACSONE SA/NV,Odoo Community Association (OCA)',
|
||||
'website': 'https://github.com/OCA/stock-logistics-warehouse',
|
||||
'depends': [
|
||||
"stock"
|
||||
],
|
||||
"version": "10.0.1.0.1",
|
||||
"category": "Warehouse",
|
||||
"maintainers": ["rousseldenis"],
|
||||
"license": "AGPL-3",
|
||||
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
|
||||
"website": "https://github.com/OCA/stock-logistics-warehouse",
|
||||
"depends": ["stock"],
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2020 ACSONE SA/NV
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from odoo.osv import expression
|
||||
from odoo import models
|
||||
from odoo.osv import expression
|
||||
|
||||
|
||||
class ProductProduct(models.Model):
|
||||
@@ -10,7 +9,8 @@ class ProductProduct(models.Model):
|
||||
_inherit = "product.product"
|
||||
|
||||
def _get_domain_locations_new(
|
||||
self, location_ids, company_id=False, compute_child=True):
|
||||
self, location_ids, company_id=False, compute_child=True
|
||||
):
|
||||
"""
|
||||
This is used to exclude locations if needed
|
||||
:param location_ids:
|
||||
@@ -19,22 +19,30 @@ class ProductProduct(models.Model):
|
||||
:return:
|
||||
"""
|
||||
domain_quant_loc, domain_move_in_loc, domain_move_out_loc = super(
|
||||
ProductProduct, self)._get_domain_locations_new(
|
||||
ProductProduct, self
|
||||
)._get_domain_locations_new(
|
||||
location_ids=location_ids,
|
||||
company_id=company_id,
|
||||
compute_child=compute_child)
|
||||
compute_child=compute_child,
|
||||
)
|
||||
excluded_location_ids = self.env.context.get("excluded_location_ids")
|
||||
if excluded_location_ids:
|
||||
domain_quant_loc = expression.AND([
|
||||
domain_quant_loc = expression.AND(
|
||||
[
|
||||
[("location_id", "not in", excluded_location_ids.ids)],
|
||||
domain_quant_loc,
|
||||
])
|
||||
domain_move_in_loc = expression.AND([
|
||||
]
|
||||
)
|
||||
domain_move_in_loc = expression.AND(
|
||||
[
|
||||
[("location_dest_id", "not in", excluded_location_ids.ids)],
|
||||
domain_quant_loc,
|
||||
])
|
||||
domain_move_out_loc = expression.AND([
|
||||
]
|
||||
)
|
||||
domain_move_out_loc = expression.AND(
|
||||
[
|
||||
[("location_id", "not in", excluded_location_ids.ids)],
|
||||
domain_quant_loc,
|
||||
])
|
||||
]
|
||||
)
|
||||
return domain_quant_loc, domain_move_in_loc, domain_move_out_loc
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2020 ACSONE SA/NV
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
@@ -7,10 +6,10 @@ from odoo import fields, models
|
||||
|
||||
class StockExcludeLocationMixin(models.AbstractModel):
|
||||
|
||||
_name = 'stock.exclude.location.mixin'
|
||||
_name = "stock.exclude.location.mixin"
|
||||
|
||||
stock_excluded_location_ids = fields.Many2many(
|
||||
comodel_name="stock.location",
|
||||
help="Fill in this field to exclude locations for product available"
|
||||
"quantities."
|
||||
"quantities.",
|
||||
)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2020 ACSONE SA/NV
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from odoo import models
|
||||
|
||||
@@ -1,26 +1,23 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2020 ACSONE SA/NV
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from odoo.tests import SavepointCase
|
||||
from odoo_test_helper import FakeModelLoader
|
||||
|
||||
from odoo.tests import SavepointCase
|
||||
|
||||
|
||||
class TestExcludeLocation(SavepointCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestExcludeLocation, cls).setUpClass()
|
||||
cls.loader = FakeModelLoader(cls.env, cls.__module__)
|
||||
cls.loader.backup_registry()
|
||||
from .common import ResPartner
|
||||
|
||||
cls.loader.update_registry((ResPartner,))
|
||||
|
||||
cls.fake = cls.env["res.partner"].create({"name": "name"})
|
||||
cls.location_shop = cls.env.ref("stock.stock_location_shop0")
|
||||
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._parent_store_compute()
|
||||
cls.product = cls.env.ref("product.product_product_4")
|
||||
@@ -55,14 +52,8 @@ class TestExcludeLocation(SavepointCase):
|
||||
self._add_stock_to_product(self.product, self.sub_location_1, 25.0)
|
||||
self.fake.stock_excluded_location_ids = self.sub_location_1
|
||||
qty = self.product.with_context(
|
||||
excluded_location_ids=self.fake.stock_excluded_location_ids).\
|
||||
qty_available
|
||||
self.assertEquals(
|
||||
50.0,
|
||||
qty
|
||||
)
|
||||
excluded_location_ids=self.fake.stock_excluded_location_ids
|
||||
).qty_available
|
||||
self.assertEquals(50.0, qty)
|
||||
qty = self.product.qty_available
|
||||
self.assertEquals(
|
||||
75.0,
|
||||
qty
|
||||
)
|
||||
self.assertEquals(75.0, qty)
|
||||
|
||||
Reference in New Issue
Block a user