Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
dhongu committed Oct 28, 2024
1 parent 6f5c197 commit e5f0d68
Show file tree
Hide file tree
Showing 22 changed files with 1,508 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ addon | version | maintainers | summary | price
[deltatech_vendor_stock](deltatech_vendor_stock/) | 15.0.1.0.5 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Vendor stock availability | Free
[deltatech_warehouse](deltatech_warehouse/) | 15.0.1.0.0 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | MRP Warehouse | Free
[deltatech_warehouse_access](deltatech_warehouse_access/) | 15.0.1.0.0 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Warehouse Access | Free
[deltatech_warehouse_arrangement](deltatech_warehouse_arrangement/) | 15.0.0.1.1 | | Manages warehouse locations, parallel to standard Odoo locations | Free
[deltatech_warranty](deltatech_warranty/) | 15.0.1.0.0 | [![danila12](https://github.com/danila12.png?size=30px)](https://github.com/danila12) | Warranty field in product, report for sale order | Free
[deltatech_watermark](deltatech_watermark/) | 15.0.3.0.0 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Watermark field | Free
[deltatech_watermark_report](deltatech_watermark_report/) | 15.0.1.0.0 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Watermark in report | Free
Expand Down
55 changes: 55 additions & 0 deletions deltatech_warehouse_arrangement/README.rst
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.
6 changes: 6 additions & 0 deletions deltatech_warehouse_arrangement/__init__.py
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
27 changes: 27 additions & 0 deletions deltatech_warehouse_arrangement/__manifest__.py
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,
}
280 changes: 280 additions & 0 deletions deltatech_warehouse_arrangement/i18n/ro.po

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions deltatech_warehouse_arrangement/models/__init__.py
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 deltatech_warehouse_arrangement/models/product_template.py
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")
57 changes: 57 additions & 0 deletions deltatech_warehouse_arrangement/models/stock_lot.py
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,
}
)
33 changes: 33 additions & 0 deletions deltatech_warehouse_arrangement/models/stock_move_line.py
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
18 changes: 18 additions & 0 deletions deltatech_warehouse_arrangement/models/stock_quant.py
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)
Loading

0 comments on commit e5f0d68

Please sign in to comment.