-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
1,508 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
=============================== | ||
Deltatech Warehouse Arrangement | ||
=============================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:c4d71d9d767e6d9c4100145117f6ad3ff9c17e9083c6d093fc1350408110fca8 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Beta | ||
.. |badge2| image:: https://img.shields.io/badge/licence-OPL--1-blue.png | ||
:target: https://www.odoo.com/documentation/master/legal/licenses.html | ||
:alt: License: OPL-1 | ||
.. |badge3| image:: https://img.shields.io/badge/github-dhongu%2Fdeltatech-lightgray.png?logo=github | ||
:target: https://github.com/dhongu/deltatech/tree/15.0/deltatech_warehouse_arrangement | ||
:alt: dhongu/deltatech | ||
|
||
|badge1| |badge2| |badge3| | ||
|
||
Features: | ||
- Manages warehouse locations, parallel to standard Odoo locations | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `Terrabit Issues <https://www.terrabit.ro/helpdesk>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
~~~~~~~ | ||
|
||
* Terrabit | ||
* Dan Stoica | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
This module is part of the `dhongu/deltatech <https://github.com/dhongu/deltatech/tree/15.0/deltatech_warehouse_arrangement>`_ project on GitHub. | ||
|
||
You are welcome to contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# © 2024 Terrabit | ||
# Dan Stoica <danila(@)terrabit(.)ro | ||
# See README.rst file on addons root folder for license details | ||
|
||
from . import models | ||
from . import wizard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# © 2024 Terrabit | ||
# Dan Stoica <danila(@)terrabit(.)ro | ||
# See README.rst file on addons root folder for license details | ||
{ | ||
"name": "Deltatech Warehouse Arrangement", | ||
"category": "Stock", | ||
"summary": "Manages warehouse locations, parallel to standard Odoo locations", | ||
"version": "15.0.0.1.1", | ||
"author": "Terrabit, Dan Stoica", | ||
"website": "https://www.terrabit.ro", | ||
"license": "OPL-1", | ||
"depends": [ | ||
"stock", | ||
"barcodes", | ||
], | ||
"data": [ | ||
"security/security.xml", | ||
"security/ir.model.access.csv", | ||
"views/warehouse_location.xml", | ||
"views/product_template.xml", | ||
"views/stock_lot.xml", | ||
"views/stock_quant.xml", | ||
"wizard/lot_set_location.xml", | ||
], | ||
"development_status": "Beta", | ||
"installable": True, | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# © 2024 Terrabit | ||
# Dan Stoica <danila(@)terrabit(.)ro | ||
# See README.rst file on addons root folder for license details | ||
|
||
from . import warehouse_location | ||
from . import product_template | ||
from . import stock_lot | ||
from . import stock_quant | ||
from . import stock_move_line |
16 changes: 16 additions & 0 deletions
16
deltatech_warehouse_arrangement/models/product_template.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# © 2024 Terrabit | ||
# Dan Stoica <danila(@)terrabit(.)ro | ||
# See README.rst file on addons root folder for license details | ||
|
||
|
||
from odoo import fields, models | ||
|
||
|
||
class ProductTemplate(models.Model): | ||
_inherit = "product.template" | ||
|
||
loc_storehouse_id = fields.Many2one("warehouse.location.storehouse", string="Storehouse") | ||
loc_zone_id = fields.Many2one("warehouse.location.zone", string="Zone") | ||
loc_shelf_id = fields.Many2one("warehouse.location.shelf", string="Shelf") | ||
loc_section_id = fields.Many2one("warehouse.location.section", string="Section") | ||
loc_rack_id = fields.Many2one("warehouse.location.rack", string="Rack") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# © 2024 Terrabit | ||
# Dan Stoica <danila(@)terrabit(.)ro | ||
# See README.rst file on addons root folder for license details | ||
|
||
|
||
from odoo import api, fields, models | ||
from odoo.tools import float_is_zero | ||
|
||
|
||
class StockLot(models.Model): | ||
_inherit = "stock.production.lot" | ||
|
||
loc_storehouse_id = fields.Many2one("warehouse.location.storehouse", string="Storehouse") | ||
loc_zone_id = fields.Many2one("warehouse.location.zone", string="Zone") | ||
loc_shelf_id = fields.Many2one("warehouse.location.shelf", string="Shelf") | ||
loc_section_id = fields.Many2one("warehouse.location.section", string="Section") | ||
loc_rack_id = fields.Many2one("warehouse.location.rack", string="Rack") | ||
|
||
@api.model_create_multi | ||
def create(self, vals_list): | ||
for vals in vals_list: | ||
product_id = self.env["product.product"].browse(vals["product_id"]) | ||
vals["loc_storehouse_id"] = product_id.loc_storehouse_id.id | ||
vals["loc_zone_id"] = product_id.loc_zone_id.id | ||
vals["loc_shelf_id"] = product_id.loc_shelf_id.id | ||
vals["loc_section_id"] = product_id.loc_section_id.id | ||
vals["loc_rack_id"] = product_id.loc_rack_id.id | ||
return super().create(vals_list) | ||
|
||
def check_if_depleted(self, location_id): | ||
""" | ||
Check if quantity becomes 0 on the stock location | ||
and delete locations if 0 | ||
:param location_id: location in which to check | ||
:return: | ||
""" | ||
for lot in self: | ||
if lot.loc_storehouse_id.location_id: | ||
stock_location_id = location_id | ||
children_location = ( | ||
self.env["stock.location"] | ||
.with_context(active_test=False) | ||
.search([("id", "child_of", stock_location_id.ids)]) | ||
) | ||
internal_children_locations = children_location.filtered(lambda l: l.usage == "internal") | ||
quants = lot.quant_ids.filtered(lambda q: q.location_id in internal_children_locations) | ||
product_qty = sum(quants.mapped("quantity")) | ||
if float_is_zero(product_qty, precision_rounding=lot.product_id.uom_id.rounding): | ||
lot.write( | ||
{ | ||
"loc_storehouse_id": False, | ||
"loc_zone_id": False, | ||
"loc_shelf_id": False, | ||
"loc_section_id": False, | ||
"loc_rack_id": False, | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# © 2024 Terrabit | ||
# Dan Stoica <danila(@)terrabit(.)ro | ||
# See README.rst file on addons root folder for license details | ||
|
||
|
||
from odoo import models | ||
|
||
|
||
class StockMoveLine(models.Model): | ||
_inherit = "stock.move.line" | ||
|
||
def _action_done(self): | ||
res = super()._action_done() | ||
for ml in self: | ||
# if a lot/serial enters the master location | ||
if ( | ||
ml.lot_id | ||
and ml.product_id.loc_storehouse_id | ||
and ml.product_id.loc_storehouse_id.location_id == ml.location_dest_id | ||
): | ||
ml.lot_id.write( | ||
{ | ||
"loc_storehouse_id": ml.product_id.loc_storehouse_id.id, | ||
"loc_zone_id": ml.product_id.loc_zone_id.id, | ||
"loc_shelf_id": ml.product_id.loc_shelf_id.id, | ||
"loc_section_id": ml.product_id.loc_section_id.id, | ||
"loc_rack_id": ml.product_id.loc_rack_id.id, | ||
} | ||
) | ||
# if a lot/serial leaves the master location and the quantity in that location remains 0 | ||
if ml.lot_id and ml.lot_id.loc_storehouse_id and ml.lot_id.loc_storehouse_id.location_id == ml.location_id: | ||
ml.lot_id.check_if_depleted(ml.location_id) | ||
return res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# © 2024 Terrabit | ||
# Dan Stoica <danila(@)terrabit(.)ro | ||
# See README.rst file on addons root folder for license details | ||
|
||
|
||
from odoo import fields, models | ||
|
||
|
||
class StockQuant(models.Model): | ||
_inherit = "stock.quant" | ||
|
||
loc_storehouse_id = fields.Many2one( | ||
"warehouse.location.storehouse", related="product_id.loc_storehouse_id", store=True | ||
) | ||
loc_zone_id = fields.Many2one("warehouse.location.zone", related="lot_id.loc_zone_id", store=True) | ||
loc_shelf_id = fields.Many2one("warehouse.location.shelf", related="lot_id.loc_shelf_id", store=True) | ||
loc_section_id = fields.Many2one("warehouse.location.section", related="lot_id.loc_section_id", store=True) | ||
loc_rack_id = fields.Many2one("warehouse.location.rack", related="lot_id.loc_rack_id", store=True) |
Oops, something went wrong.