Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0][UPD]warehouse arrangement: modif automatic placement of the lots #1783

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ addon | version | maintainers | summary | price
[deltatech_tracking_2performant](deltatech_tracking_2performant/) | 14.0.1.0.0 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | 2Performant tracking | Free
[deltatech_vendor_stock](deltatech_vendor_stock/) | 14.0.1.0.1 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Vendor stock availability | Free
[deltatech_warehouse](deltatech_warehouse/) | 14.0.1.0.0 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | MRP Warehouse | Free
[deltatech_warehouse_arrangement](deltatech_warehouse_arrangement/) | 14.0.0.0.1 | | Manages warehouse locations, parallel to standard Odoo locations | Free
[deltatech_warehouse_arrangement](deltatech_warehouse_arrangement/) | 14.0.0.1.0 | | Manages warehouse locations, parallel to standard Odoo locations | Free
[deltatech_watermark](deltatech_watermark/) | 14.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/) | 14.0.1.0.0 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Watermark in report | Free
[deltatech_website_access_design](deltatech_website_access_design/) | 14.0.1.0.1 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Access for web designer | Free
Expand Down
2 changes: 1 addition & 1 deletion deltatech_warehouse_arrangement/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Deltatech Warehouse Arrangement
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:929d262593f80e079dcc6d5f76a40a749682d60704ca9fec0dfa4a6ab8e1e9a3
!! source digest: sha256:ea2343f6ca57915d8a62b035392925c4c7e5c57d0b608921826c2e9a996ae002
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down
6 changes: 4 additions & 2 deletions deltatech_warehouse_arrangement/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
"name": "Deltatech Warehouse Arrangement",
"category": "Stock",
"summary": "Manages warehouse locations, parallel to standard Odoo locations",
"version": "14.0.0.0.1",
"version": "14.0.0.1.0",
"author": "Terrabit, Dan Stoica",
"website": "https://www.terrabit.ro",
"license": "OPL-1",
"depends": ["stock"],
"depends": [
"stock",
],
"data": [
"security/security.xml",
"security/ir.model.access.csv",
Expand Down
52 changes: 38 additions & 14 deletions deltatech_warehouse_arrangement/i18n/ro.po
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-09-04 04:31+0000\n"
"PO-Revision-Date: 2024-09-04 04:31+0000\n"
"POT-Creation-Date: 2024-09-19 04:14+0000\n"
"PO-Revision-Date: 2024-09-19 04:14+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
Expand Down Expand Up @@ -56,6 +56,10 @@ msgstr "Afiseaza nume"

#. module: deltatech_warehouse_arrangement
#: model:ir.model.fields,field_description:deltatech_warehouse_arrangement.field_warehouse_location_rack__full_name
#: model:ir.model.fields,field_description:deltatech_warehouse_arrangement.field_warehouse_location_section__full_name
#: model:ir.model.fields,field_description:deltatech_warehouse_arrangement.field_warehouse_location_shelf__full_name
#: model:ir.model.fields,field_description:deltatech_warehouse_arrangement.field_warehouse_location_storehouse__full_name
#: model:ir.model.fields,field_description:deltatech_warehouse_arrangement.field_warehouse_location_zone__full_name
msgid "Full Name"
msgstr ""

Expand Down Expand Up @@ -134,8 +138,6 @@ msgstr "Poziții de stoc"

#. module: deltatech_warehouse_arrangement
#: model:ir.actions.act_window,name:deltatech_warehouse_arrangement.action_rack
#: model:ir.model.fields,field_description:deltatech_warehouse_arrangement.field_marketplace_product__loc_rack_id
#: model:ir.model.fields,field_description:deltatech_warehouse_arrangement.field_marketplace_product_template__loc_rack_id
#: model:ir.model.fields,field_description:deltatech_warehouse_arrangement.field_product_product__loc_rack_id
#: model:ir.model.fields,field_description:deltatech_warehouse_arrangement.field_product_template__loc_rack_id
#: model:ir.model.fields,field_description:deltatech_warehouse_arrangement.field_stock_production_lot__loc_rack_id
Expand All @@ -147,10 +149,14 @@ msgstr "Poziții de stoc"
msgid "Rack"
msgstr "Polița"

#. module: deltatech_warehouse_arrangement
#: code:addons/deltatech_warehouse_arrangement/models/warehouse_location.py:0
#, python-format
msgid "Rack: "
msgstr "Polița: "

#. module: deltatech_warehouse_arrangement
#: model:ir.actions.act_window,name:deltatech_warehouse_arrangement.action_section
#: model:ir.model.fields,field_description:deltatech_warehouse_arrangement.field_marketplace_product__loc_section_id
#: model:ir.model.fields,field_description:deltatech_warehouse_arrangement.field_marketplace_product_template__loc_section_id
#: model:ir.model.fields,field_description:deltatech_warehouse_arrangement.field_product_product__loc_section_id
#: model:ir.model.fields,field_description:deltatech_warehouse_arrangement.field_product_template__loc_section_id
#: model:ir.model.fields,field_description:deltatech_warehouse_arrangement.field_stock_production_lot__loc_section_id
Expand All @@ -163,6 +169,12 @@ msgstr "Polița"
msgid "Section"
msgstr "Secțiune"

#. module: deltatech_warehouse_arrangement
#: code:addons/deltatech_warehouse_arrangement/models/warehouse_location.py:0
#, python-format
msgid "Section: "
msgstr "Secțiune: "

#. module: deltatech_warehouse_arrangement
#: model:ir.model.fields,field_description:deltatech_warehouse_arrangement.field_warehouse_location_rack__sequence
#: model:ir.model.fields,field_description:deltatech_warehouse_arrangement.field_warehouse_location_section__sequence
Expand All @@ -174,8 +186,6 @@ msgstr "Secvența"

#. module: deltatech_warehouse_arrangement
#: model:ir.actions.act_window,name:deltatech_warehouse_arrangement.action_shelf
#: model:ir.model.fields,field_description:deltatech_warehouse_arrangement.field_marketplace_product__loc_shelf_id
#: model:ir.model.fields,field_description:deltatech_warehouse_arrangement.field_marketplace_product_template__loc_shelf_id
#: model:ir.model.fields,field_description:deltatech_warehouse_arrangement.field_product_product__loc_shelf_id
#: model:ir.model.fields,field_description:deltatech_warehouse_arrangement.field_product_template__loc_shelf_id
#: model:ir.model.fields,field_description:deltatech_warehouse_arrangement.field_stock_production_lot__loc_shelf_id
Expand All @@ -188,10 +198,14 @@ msgstr "Secvența"
msgid "Shelf"
msgstr "Raft"

#. module: deltatech_warehouse_arrangement
#: code:addons/deltatech_warehouse_arrangement/models/warehouse_location.py:0
#, python-format
msgid "Shelf: "
msgstr "Raft: "

#. module: deltatech_warehouse_arrangement
#: model:ir.actions.act_window,name:deltatech_warehouse_arrangement.action_storehouse
#: model:ir.model.fields,field_description:deltatech_warehouse_arrangement.field_marketplace_product__loc_storehouse_id
#: model:ir.model.fields,field_description:deltatech_warehouse_arrangement.field_marketplace_product_template__loc_storehouse_id
#: model:ir.model.fields,field_description:deltatech_warehouse_arrangement.field_product_product__loc_storehouse_id
#: model:ir.model.fields,field_description:deltatech_warehouse_arrangement.field_product_template__loc_storehouse_id
#: model:ir.model.fields,field_description:deltatech_warehouse_arrangement.field_stock_production_lot__loc_storehouse_id
Expand All @@ -205,7 +219,13 @@ msgid "Storehouse"
msgstr "Hala"

#. module: deltatech_warehouse_arrangement
#: model:ir.model.fields,field_description:deltatech_warehouse_arrangement.field_warehouse_location_storehouse__warehouse_id
#: code:addons/deltatech_warehouse_arrangement/models/warehouse_location.py:0
#, python-format
msgid "Storehouse: "
msgstr "Hala: "

#. module: deltatech_warehouse_arrangement
#: model:ir.model.fields,field_description:deltatech_warehouse_arrangement.field_warehouse_location_storehouse__location_id
msgid "Warehouse"
msgstr "Depozit"

Expand Down Expand Up @@ -241,8 +261,6 @@ msgstr "Zona"

#. module: deltatech_warehouse_arrangement
#: model:ir.actions.act_window,name:deltatech_warehouse_arrangement.action_zone
#: model:ir.model.fields,field_description:deltatech_warehouse_arrangement.field_marketplace_product__loc_zone_id
#: model:ir.model.fields,field_description:deltatech_warehouse_arrangement.field_marketplace_product_template__loc_zone_id
#: model:ir.model.fields,field_description:deltatech_warehouse_arrangement.field_product_product__loc_zone_id
#: model:ir.model.fields,field_description:deltatech_warehouse_arrangement.field_product_template__loc_zone_id
#: model:ir.model.fields,field_description:deltatech_warehouse_arrangement.field_stock_production_lot__loc_zone_id
Expand All @@ -253,4 +271,10 @@ msgstr "Zona"
#: model_terms:ir.ui.view,arch_db:deltatech_warehouse_arrangement.view_zone_form
#: model_terms:ir.ui.view,arch_db:deltatech_warehouse_arrangement.view_zone_tree
msgid "Zone"
msgstr "Zona"
msgstr "Zona"

#. module: deltatech_warehouse_arrangement
#: code:addons/deltatech_warehouse_arrangement/models/warehouse_location.py:0
#, python-format
msgid "Zone: "
msgstr "Zona: "
1 change: 1 addition & 0 deletions deltatech_warehouse_arrangement/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
from . import product_template
from . import stock_lot
from . import stock_quant
from . import stock_move_line
30 changes: 30 additions & 0 deletions deltatech_warehouse_arrangement/models/stock_lot.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@


from odoo import api, fields, models
from odoo.tools import float_is_zero


class StockLot(models.Model):
Expand All @@ -25,3 +26,32 @@ def create(self, vals_list):
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
19 changes: 4 additions & 15 deletions deltatech_warehouse_arrangement/models/stock_quant.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,7 @@ class StockQuant(models.Model):
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="product_id.loc_zone_id", store=True)
loc_shelf_id = fields.Many2one("warehouse.location.shelf", related="product_id.loc_shelf_id", store=True)
loc_section_id = fields.Many2one("warehouse.location.section", related="product_id.loc_section_id", store=True)
loc_rack_id = fields.Many2one("warehouse.location.rack", related="product_id.loc_rack_id", store=True)

# @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)
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
Loading