From 0b526d4bec77ef394694337ad7c2af2064899696 Mon Sep 17 00:00:00 2001 From: danila12 Date: Wed, 25 Sep 2024 14:05:43 +0300 Subject: [PATCH] modif automatic placement of the lots --- README.md | 2 +- deltatech_warehouse_arrangement/README.rst | 2 +- .../__manifest__.py | 6 +- deltatech_warehouse_arrangement/i18n/ro.po | 52 +++++--- .../models/__init__.py | 1 + .../models/stock_lot.py | 30 +++++ .../models/stock_move_line.py | 33 +++++ .../models/stock_quant.py | 19 +-- .../models/warehouse_location.py | 119 ++++++++++++++++-- .../static/description/index.html | 2 +- .../views/warehouse_location.xml | 9 +- 11 files changed, 230 insertions(+), 45 deletions(-) create mode 100644 deltatech_warehouse_arrangement/models/stock_move_line.py diff --git a/README.md b/README.md index 20b7f1714..a59751f18 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/deltatech_warehouse_arrangement/README.rst b/deltatech_warehouse_arrangement/README.rst index a1d02c08d..6eeba9dbe 100644 --- a/deltatech_warehouse_arrangement/README.rst +++ b/deltatech_warehouse_arrangement/README.rst @@ -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 diff --git a/deltatech_warehouse_arrangement/__manifest__.py b/deltatech_warehouse_arrangement/__manifest__.py index 220b74215..f362f80bd 100644 --- a/deltatech_warehouse_arrangement/__manifest__.py +++ b/deltatech_warehouse_arrangement/__manifest__.py @@ -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", diff --git a/deltatech_warehouse_arrangement/i18n/ro.po b/deltatech_warehouse_arrangement/i18n/ro.po index 34ee00c11..9c084dcae 100644 --- a/deltatech_warehouse_arrangement/i18n/ro.po +++ b/deltatech_warehouse_arrangement/i18n/ro.po @@ -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" @@ -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 "" @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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" @@ -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 @@ -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" \ No newline at end of file +msgstr "Zona" + +#. module: deltatech_warehouse_arrangement +#: code:addons/deltatech_warehouse_arrangement/models/warehouse_location.py:0 +#, python-format +msgid "Zone: " +msgstr "Zona: " \ No newline at end of file diff --git a/deltatech_warehouse_arrangement/models/__init__.py b/deltatech_warehouse_arrangement/models/__init__.py index 44bb11bd1..c1f6ec0bf 100644 --- a/deltatech_warehouse_arrangement/models/__init__.py +++ b/deltatech_warehouse_arrangement/models/__init__.py @@ -6,3 +6,4 @@ from . import product_template from . import stock_lot from . import stock_quant +from . import stock_move_line diff --git a/deltatech_warehouse_arrangement/models/stock_lot.py b/deltatech_warehouse_arrangement/models/stock_lot.py index 00f28a26a..c7c7159c2 100644 --- a/deltatech_warehouse_arrangement/models/stock_lot.py +++ b/deltatech_warehouse_arrangement/models/stock_lot.py @@ -4,6 +4,7 @@ from odoo import api, fields, models +from odoo.tools import float_is_zero class StockLot(models.Model): @@ -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, + } + ) diff --git a/deltatech_warehouse_arrangement/models/stock_move_line.py b/deltatech_warehouse_arrangement/models/stock_move_line.py new file mode 100644 index 000000000..e87389cdc --- /dev/null +++ b/deltatech_warehouse_arrangement/models/stock_move_line.py @@ -0,0 +1,33 @@ +# © 2024 Terrabit +# Dan Stoica Deltatech Warehouse Arrangement !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:929d262593f80e079dcc6d5f76a40a749682d60704ca9fec0dfa4a6ab8e1e9a3 +!! source digest: sha256:ea2343f6ca57915d8a62b035392925c4c7e5c57d0b608921826c2e9a996ae002 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Beta License: OPL-1 dhongu/deltatech

diff --git a/deltatech_warehouse_arrangement/views/warehouse_location.xml b/deltatech_warehouse_arrangement/views/warehouse_location.xml index 0d6dd30c2..1fc1528a7 100644 --- a/deltatech_warehouse_arrangement/views/warehouse_location.xml +++ b/deltatech_warehouse_arrangement/views/warehouse_location.xml @@ -8,7 +8,8 @@ - + + @@ -23,7 +24,8 @@ - + + @@ -60,6 +62,7 @@ + @@ -96,6 +99,7 @@ + @@ -132,6 +136,7 @@ +