Skip to content

Commit 7f1bf7d

Browse files
[ADD] stock_available_exclude_location: add new module
1 parent ffbfd6f commit 7f1bf7d

File tree

17 files changed

+768
-0
lines changed

17 files changed

+768
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../stock_available_exclude_location
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import setuptools
2+
3+
setuptools.setup(
4+
setup_requires=['setuptools-odoo'],
5+
odoo_addon=True,
6+
)
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
================================
2+
Stock Available Exclude Location
3+
================================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:2f16c2fabd3459801329b642fc18f7ab592c16293e7ae5f42e8ea9b4de67143e
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Alpha
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github
20+
:target: https://github.com/OCA/stock-logistics-warehouse/tree/14.0/stock_available_exclude_location
21+
:alt: OCA/stock-logistics-warehouse
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-14-0/stock-logistics-warehouse-14-0-stock_available_exclude_location
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-warehouse&target_branch=14.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module allow defining excluded locations for product availability.
32+
33+
.. IMPORTANT::
34+
This is an alpha version, the data model and design can change at any time without warning.
35+
Only for development or testing purpose, do not use in production.
36+
`More details on development status <https://odoo-community.org/page/development-status>`_
37+
38+
**Table of contents**
39+
40+
.. contents::
41+
:local:
42+
43+
Configuration
44+
=============
45+
46+
Go to **Inventory** > **Configuration** > **Settings**.
47+
48+
- Find the Products section.
49+
- In Excluded Locations for Availability, select the excluded locations.
50+
- The selected locations and his children will be excluded from product availability.
51+
52+
Bug Tracker
53+
===========
54+
55+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-warehouse/issues>`_.
56+
In case of trouble, please check there if your issue has already been reported.
57+
If you spotted it first, help us to smash it by providing a detailed and welcomed
58+
`feedback <https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_available_exclude_location%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
59+
60+
Do not contact contributors directly about support or help with technical issues.
61+
62+
Credits
63+
=======
64+
65+
Authors
66+
~~~~~~~
67+
68+
* Escodoo
69+
70+
Contributors
71+
~~~~~~~~~~~~
72+
73+
* `Escodoo <https://escodoo.com.br>`_:
74+
75+
* Marcel Savegnago <[email protected]>
76+
* Wesley Oliveira <[email protected]>
77+
78+
Maintainers
79+
~~~~~~~~~~~
80+
81+
This module is maintained by the OCA.
82+
83+
.. image:: https://odoo-community.org/logo.png
84+
:alt: Odoo Community Association
85+
:target: https://odoo-community.org
86+
87+
OCA, or the Odoo Community Association, is a nonprofit organization whose
88+
mission is to support the collaborative development of Odoo features and
89+
promote its widespread use.
90+
91+
This module is part of the `OCA/stock-logistics-warehouse <https://github.com/OCA/stock-logistics-warehouse/tree/14.0/stock_available_exclude_location>`_ project on GitHub.
92+
93+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright 2024 - TODAY, Escodoo
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
{
5+
"name": "Stock Available Exclude Location",
6+
"summary": """
7+
Exclude locations for product available quantities""",
8+
"version": "14.0.1.0.0",
9+
"category": "Stock",
10+
"license": "AGPL-3",
11+
"author": "Escodoo,Odoo Community Association (OCA)",
12+
"website": "https://github.com/OCA/stock-logistics-warehouse",
13+
"depends": [
14+
"stock_available_base_exclude_location",
15+
"stock_location_children",
16+
],
17+
"data": ["views/res_config_settings.xml"],
18+
"installable": True,
19+
"development_status": "Alpha",
20+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from . import product_product
2+
from . import res_company
3+
from . import res_config_settings
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Copyright 2024 - TODAY, Wesley Oliveira <[email protected]>
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from odoo import api, fields, models
5+
6+
7+
class ProductProduct(models.Model):
8+
9+
_inherit = "product.product"
10+
11+
excluded_location_ids = fields.Many2many(
12+
comodel_name="stock.location",
13+
string="Locations to Exclude as Available",
14+
compute="_compute_excluded_location_ids",
15+
readonly=True,
16+
)
17+
18+
@api.depends()
19+
def _compute_excluded_location_ids(self):
20+
self.update({"excluded_location_ids": False})
21+
stock_quants = self.env["stock.quant"].search(
22+
[
23+
("product_id", "in", self.ids),
24+
("on_hand", "=", True),
25+
]
26+
)
27+
for product in self:
28+
product_quants = stock_quants.filtered(lambda x: x.product_id == product)
29+
if product_quants:
30+
company_ids = product_quants.mapped(lambda x: x.company_id)
31+
excluded_ids = company_ids.mapped(
32+
lambda x: x.stock_excluded_location_ids
33+
)
34+
if excluded_ids:
35+
for excluded_location in excluded_ids:
36+
excluded_ids |= excluded_location.children_ids
37+
product.excluded_location_ids = excluded_ids
38+
39+
def _compute_quantities_dict(
40+
self, lot_id, owner_id, package_id, from_date=False, to_date=False
41+
):
42+
context = dict(self._context, excluded_location_ids=self.excluded_location_ids)
43+
return super(
44+
ProductProduct, self.with_context(context)
45+
)._compute_quantities_dict(lot_id, owner_id, package_id, from_date, to_date)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copyright 2024 - TODAY, Wesley Oliveira <[email protected]>
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from odoo import models
5+
6+
7+
class ResCompany(models.Model):
8+
9+
_name = "res.company"
10+
_inherit = ["res.company", "stock.exclude.location.mixin"]
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright 2024 - TODAY, Wesley Oliveira <[email protected]>
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from odoo import fields, models
5+
6+
7+
class ResConfigSettings(models.TransientModel):
8+
9+
_inherit = "res.config.settings"
10+
11+
stock_excluded_location_ids = fields.Many2many(
12+
comodel_name="stock.location",
13+
related="company_id.stock_excluded_location_ids",
14+
string="Excluded Locations for Product Availability",
15+
help="Fill in this field to exclude locations for product available quantities.",
16+
readonly=False,
17+
)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Go to **Inventory** > **Configuration** > **Settings**.
2+
3+
- Find the Products section.
4+
- In Excluded Locations for Availability, select the excluded locations.
5+
- The selected locations and his children will be excluded from product availability.

0 commit comments

Comments
 (0)