From efae5a6eca56037a3cb7fd79f2c2bb21713e7f71 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Mon, 7 Oct 2024 09:10:43 +0200 Subject: [PATCH] [16.0][ADD] stock_orderpoint_first_dates: In Invetory - Operations - Replenishment, new fields "First Reception Date", and "First Shipping Date". --- .../odoo/addons/stock_orderpoint_first_dates | 1 + setup/stock_orderpoint_first_dates/setup.py | 6 +++ stock_orderpoint_first_dates/README.rst | 29 +++++++++++++ stock_orderpoint_first_dates/__init__.py | 1 + stock_orderpoint_first_dates/__manifest__.py | 15 +++++++ stock_orderpoint_first_dates/i18n/ca_ES.po | 41 +++++++++++++++++++ stock_orderpoint_first_dates/i18n/en_GB.po | 41 +++++++++++++++++++ stock_orderpoint_first_dates/i18n/es.po | 41 +++++++++++++++++++ stock_orderpoint_first_dates/i18n/fr.po | 41 +++++++++++++++++++ .../i18n/stock_orderpoint_first_dates.pot | 41 +++++++++++++++++++ .../models/__init__.py | 1 + .../models/stock_warehouse_orderpoint.py | 38 +++++++++++++++++ .../stock_warehouse_orderpoint_views.xml | 23 +++++++++++ 13 files changed, 319 insertions(+) create mode 120000 setup/stock_orderpoint_first_dates/odoo/addons/stock_orderpoint_first_dates create mode 100644 setup/stock_orderpoint_first_dates/setup.py create mode 100644 stock_orderpoint_first_dates/README.rst create mode 100644 stock_orderpoint_first_dates/__init__.py create mode 100644 stock_orderpoint_first_dates/__manifest__.py create mode 100644 stock_orderpoint_first_dates/i18n/ca_ES.po create mode 100644 stock_orderpoint_first_dates/i18n/en_GB.po create mode 100644 stock_orderpoint_first_dates/i18n/es.po create mode 100644 stock_orderpoint_first_dates/i18n/fr.po create mode 100644 stock_orderpoint_first_dates/i18n/stock_orderpoint_first_dates.pot create mode 100644 stock_orderpoint_first_dates/models/__init__.py create mode 100644 stock_orderpoint_first_dates/models/stock_warehouse_orderpoint.py create mode 100644 stock_orderpoint_first_dates/views/stock_warehouse_orderpoint_views.xml diff --git a/setup/stock_orderpoint_first_dates/odoo/addons/stock_orderpoint_first_dates b/setup/stock_orderpoint_first_dates/odoo/addons/stock_orderpoint_first_dates new file mode 120000 index 0000000000..c7ce24a48d --- /dev/null +++ b/setup/stock_orderpoint_first_dates/odoo/addons/stock_orderpoint_first_dates @@ -0,0 +1 @@ +../../../../stock_orderpoint_first_dates \ No newline at end of file diff --git a/setup/stock_orderpoint_first_dates/setup.py b/setup/stock_orderpoint_first_dates/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/stock_orderpoint_first_dates/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_orderpoint_first_dates/README.rst b/stock_orderpoint_first_dates/README.rst new file mode 100644 index 0000000000..5f32471271 --- /dev/null +++ b/stock_orderpoint_first_dates/README.rst @@ -0,0 +1,29 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +============================ +Stock orderpoint first dates +============================ + +* In Invetory - Operations - Replenishment, new fields "First Reception Date", + and "First Shipping Date". + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, +please check there if your issue has already been reported. If you spotted +it first, help us smash it by providing detailed and welcomed feedback. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Contributors +------------ + +* Ana Juaristi +* Alfredo de la Fuente diff --git a/stock_orderpoint_first_dates/__init__.py b/stock_orderpoint_first_dates/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/stock_orderpoint_first_dates/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/stock_orderpoint_first_dates/__manifest__.py b/stock_orderpoint_first_dates/__manifest__.py new file mode 100644 index 0000000000..54ad0bf59c --- /dev/null +++ b/stock_orderpoint_first_dates/__manifest__.py @@ -0,0 +1,15 @@ +# Copyright 2024 Alfredo de la Fuente - AvanzOSC +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +{ + "name": "Stock Orderpoint First Dates", + "version": "16.0.1.0.0", + "license": "AGPL-3", + "author": "Avanzosc", + "category": "Inventory/Inventory", + "website": "https://github.com/avanzosc/odoo-addons", + "depends": ["stock"], + "data": [ + "views/stock_warehouse_orderpoint_views.xml", + ], + "installable": True, +} diff --git a/stock_orderpoint_first_dates/i18n/ca_ES.po b/stock_orderpoint_first_dates/i18n/ca_ES.po new file mode 100644 index 0000000000..4658ecff33 --- /dev/null +++ b/stock_orderpoint_first_dates/i18n/ca_ES.po @@ -0,0 +1,41 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_orderpoint_first_dates +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-10-07 07:02+0000\n" +"PO-Revision-Date: 2024-10-07 07:02+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: stock_orderpoint_first_dates +#: model:ir.model.fields,field_description:stock_orderpoint_first_dates.field_stock_move__date_deadline_without_hour +msgid "Date Deadline Without Hour" +msgstr "" + +#. module: stock_orderpoint_first_dates +#: model:ir.model.fields,field_description:stock_orderpoint_first_dates.field_stock_warehouse_orderpoint__first_reception_date +msgid "First Reception Date" +msgstr "" + +#. module: stock_orderpoint_first_dates +#: model:ir.model.fields,field_description:stock_orderpoint_first_dates.field_stock_warehouse_orderpoint__first_shipping_date +msgid "First Shipping Date" +msgstr "" + +#. module: stock_orderpoint_first_dates +#: model:ir.model,name:stock_orderpoint_first_dates.model_stock_warehouse_orderpoint +msgid "Minimum Inventory Rule" +msgstr "Regla d'inventari mínim" + +#. module: stock_orderpoint_first_dates +#: model:ir.model,name:stock_orderpoint_first_dates.model_stock_move +msgid "Stock Move" +msgstr "Moviment d'estoc" diff --git a/stock_orderpoint_first_dates/i18n/en_GB.po b/stock_orderpoint_first_dates/i18n/en_GB.po new file mode 100644 index 0000000000..21a92c6b2c --- /dev/null +++ b/stock_orderpoint_first_dates/i18n/en_GB.po @@ -0,0 +1,41 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_orderpoint_first_dates +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-10-07 07:03+0000\n" +"PO-Revision-Date: 2024-10-07 07:03+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: stock_orderpoint_first_dates +#: model:ir.model.fields,field_description:stock_orderpoint_first_dates.field_stock_move__date_deadline_without_hour +msgid "Date Deadline Without Hour" +msgstr "" + +#. module: stock_orderpoint_first_dates +#: model:ir.model.fields,field_description:stock_orderpoint_first_dates.field_stock_warehouse_orderpoint__first_reception_date +msgid "First Reception Date" +msgstr "" + +#. module: stock_orderpoint_first_dates +#: model:ir.model.fields,field_description:stock_orderpoint_first_dates.field_stock_warehouse_orderpoint__first_shipping_date +msgid "First Shipping Date" +msgstr "" + +#. module: stock_orderpoint_first_dates +#: model:ir.model,name:stock_orderpoint_first_dates.model_stock_warehouse_orderpoint +msgid "Minimum Inventory Rule" +msgstr "" + +#. module: stock_orderpoint_first_dates +#: model:ir.model,name:stock_orderpoint_first_dates.model_stock_move +msgid "Stock Move" +msgstr "" diff --git a/stock_orderpoint_first_dates/i18n/es.po b/stock_orderpoint_first_dates/i18n/es.po new file mode 100644 index 0000000000..a394103c94 --- /dev/null +++ b/stock_orderpoint_first_dates/i18n/es.po @@ -0,0 +1,41 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_orderpoint_first_dates +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-10-07 07:03+0000\n" +"PO-Revision-Date: 2024-10-07 07:03+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: stock_orderpoint_first_dates +#: model:ir.model.fields,field_description:stock_orderpoint_first_dates.field_stock_move__date_deadline_without_hour +msgid "Date Deadline Without Hour" +msgstr "Fecha límite sin hora" + +#. module: stock_orderpoint_first_dates +#: model:ir.model.fields,field_description:stock_orderpoint_first_dates.field_stock_warehouse_orderpoint__first_reception_date +msgid "First Reception Date" +msgstr "Fecha primera recepción" + +#. module: stock_orderpoint_first_dates +#: model:ir.model.fields,field_description:stock_orderpoint_first_dates.field_stock_warehouse_orderpoint__first_shipping_date +msgid "First Shipping Date" +msgstr "Fecha primer envío" + +#. module: stock_orderpoint_first_dates +#: model:ir.model,name:stock_orderpoint_first_dates.model_stock_warehouse_orderpoint +msgid "Minimum Inventory Rule" +msgstr "Regla de inventario mínimo" + +#. module: stock_orderpoint_first_dates +#: model:ir.model,name:stock_orderpoint_first_dates.model_stock_move +msgid "Stock Move" +msgstr "Movimiento de existencias" diff --git a/stock_orderpoint_first_dates/i18n/fr.po b/stock_orderpoint_first_dates/i18n/fr.po new file mode 100644 index 0000000000..b1983bd7bb --- /dev/null +++ b/stock_orderpoint_first_dates/i18n/fr.po @@ -0,0 +1,41 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_orderpoint_first_dates +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-10-07 07:03+0000\n" +"PO-Revision-Date: 2024-10-07 07:03+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: stock_orderpoint_first_dates +#: model:ir.model.fields,field_description:stock_orderpoint_first_dates.field_stock_move__date_deadline_without_hour +msgid "Date Deadline Without Hour" +msgstr "" + +#. module: stock_orderpoint_first_dates +#: model:ir.model.fields,field_description:stock_orderpoint_first_dates.field_stock_warehouse_orderpoint__first_reception_date +msgid "First Reception Date" +msgstr "" + +#. module: stock_orderpoint_first_dates +#: model:ir.model.fields,field_description:stock_orderpoint_first_dates.field_stock_warehouse_orderpoint__first_shipping_date +msgid "First Shipping Date" +msgstr "" + +#. module: stock_orderpoint_first_dates +#: model:ir.model,name:stock_orderpoint_first_dates.model_stock_warehouse_orderpoint +msgid "Minimum Inventory Rule" +msgstr "Règle de stock minimum" + +#. module: stock_orderpoint_first_dates +#: model:ir.model,name:stock_orderpoint_first_dates.model_stock_move +msgid "Stock Move" +msgstr "Mouvement de stock" diff --git a/stock_orderpoint_first_dates/i18n/stock_orderpoint_first_dates.pot b/stock_orderpoint_first_dates/i18n/stock_orderpoint_first_dates.pot new file mode 100644 index 0000000000..b8edb674a5 --- /dev/null +++ b/stock_orderpoint_first_dates/i18n/stock_orderpoint_first_dates.pot @@ -0,0 +1,41 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_orderpoint_first_dates +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-10-07 07:02+0000\n" +"PO-Revision-Date: 2024-10-07 07:02+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: stock_orderpoint_first_dates +#: model:ir.model.fields,field_description:stock_orderpoint_first_dates.field_stock_move__date_deadline_without_hour +msgid "Date Deadline Without Hour" +msgstr "" + +#. module: stock_orderpoint_first_dates +#: model:ir.model.fields,field_description:stock_orderpoint_first_dates.field_stock_warehouse_orderpoint__first_reception_date +msgid "First Reception Date" +msgstr "" + +#. module: stock_orderpoint_first_dates +#: model:ir.model.fields,field_description:stock_orderpoint_first_dates.field_stock_warehouse_orderpoint__first_shipping_date +msgid "First Shipping Date" +msgstr "" + +#. module: stock_orderpoint_first_dates +#: model:ir.model,name:stock_orderpoint_first_dates.model_stock_warehouse_orderpoint +msgid "Minimum Inventory Rule" +msgstr "" + +#. module: stock_orderpoint_first_dates +#: model:ir.model,name:stock_orderpoint_first_dates.model_stock_move +msgid "Stock Move" +msgstr "" diff --git a/stock_orderpoint_first_dates/models/__init__.py b/stock_orderpoint_first_dates/models/__init__.py new file mode 100644 index 0000000000..5024fb8c70 --- /dev/null +++ b/stock_orderpoint_first_dates/models/__init__.py @@ -0,0 +1 @@ +from . import stock_warehouse_orderpoint diff --git a/stock_orderpoint_first_dates/models/stock_warehouse_orderpoint.py b/stock_orderpoint_first_dates/models/stock_warehouse_orderpoint.py new file mode 100644 index 0000000000..1a9066a58e --- /dev/null +++ b/stock_orderpoint_first_dates/models/stock_warehouse_orderpoint.py @@ -0,0 +1,38 @@ +# Copyright 2024 Alfredo de la Fuente - AvanzOSC +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from odoo import fields, models + + +class StockWarehouseOrderpoint(models.Model): + _inherit = "stock.warehouse.orderpoint" + + first_reception_date = fields.Datetime( + compute="_compute_moves_reception_first_date" + ) + first_shipping_date = fields.Datetime(compute="_compute_moves_shipping_first_date") + + def _compute_moves_reception_first_date(self): + for orderpoint in self: + first_reception_date = False + moves = orderpoint.product_id.stock_move_ids.filtered( + lambda x: x.location_dest_id == orderpoint.location_id + and x.location_id.usage != "internal" + and x.location_dest_id.usage == "internal" + and x.state not in ("draft", "cancel", "done") + ) + if moves: + first_reception_date = min(moves.mapped("date")) + orderpoint.first_reception_date = first_reception_date + + def _compute_moves_shipping_first_date(self): + for orderpoint in self: + first_shipping_date = False + moves = orderpoint.product_id.stock_move_ids.filtered( + lambda x: x.location_id == orderpoint.location_id + and x.location_id.usage == "internal" + and x.location_dest_id.usage != "internal" + and x.state not in ("draft", "cancel", "done") + ) + if moves: + first_shipping_date = min(moves.mapped("date")) + orderpoint.first_shipping_date = first_shipping_date diff --git a/stock_orderpoint_first_dates/views/stock_warehouse_orderpoint_views.xml b/stock_orderpoint_first_dates/views/stock_warehouse_orderpoint_views.xml new file mode 100644 index 0000000000..f81bcd3359 --- /dev/null +++ b/stock_orderpoint_first_dates/views/stock_warehouse_orderpoint_views.xml @@ -0,0 +1,23 @@ + + + + stock.warehouse.orderpoint + + + + + + + + +